Lưu Tài liệu sang Định dạng trang Cố định

Contents
[ ]

Sau khi bố cục trang được xây dựng và hình dạng của các đối tượng và vị trí của chúng trên trang được tính toán, tài liệu có thể được lưu ở định dạng trang cố định được Aspose.Words hỗ trợ.

Khi lưu tài liệu sang định dạng trang cố định, các tùy chọn kết xuất chung cho tất cả các định dạng này có thể được sử dụng. Họ cho phép kiểm soát:

Ví dụ dưới đây trình bày cách lưu tài liệu sang định dạng JPEG bằng phương thức Save và các tùy chọn kết xuất:

For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-C
// Open the document.
System::SharedPtr<Document> doc = System::MakeObject<Document>(inputDataDir + u"Rendering.doc");
// Save as a JPEG image file with default options
System::String outputPathDefault = outputDataDir + u"Rendering.JpegDefaultOptions.jpg";
doc->Save(outputPathDefault);
// Save document to stream as a JPEG with default options
System::SharedPtr<MemoryStream> docStream = new MemoryStream();
doc->Save(docStream, SaveFormat::Jpeg);
// Rewind the stream position back to the beginning, ready for use
docStream->Seek(0, SeekOrigin::Begin);
// Save document to a JPEG image with specified options.
// Render the third page only and set the JPEG quality to 80%
// In this case we need to pass the desired SaveFormat to the ImageSaveOptions constructor
// to signal what type of image to save as.
System::SharedPtr<ImageSaveOptions> options = System::MakeObject<ImageSaveOptions>(SaveFormat::Tiff);
auto pageRange = System::MakeObject<PageRange>(0, 1);
options->set_PageSet(System::MakeObject<PageSet>(System::MakeArray<System::SharedPtr<PageRange>>({ pageRange })));
options->set_JpegQuality(80);
System::String outputPath = outputDataDir + u"Rendering.JpegCustomOptions.jpg";
doc->Save(outputPath, options);