Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
Purpose Summary. What is this page about?
This page explains how to use Aspose.Words for Python via .NET to export multi‑page documents to raster image formats, detailing supported formats, MultiPageLayout options, and providing code examples for various layouts and customizations.
Aspose.Words for Python via .NET allows users to export multi-page documents to raster images. This can be useful for generating previews, archives, or visual representations of documents for non-editable use.
Aspose.Words supports multi-page export to the following raster image formats:
The feature of exporting a multi-page document to an image is implemented using the MultiPageLayout class – you can specify how the pages should be organized when saving to an image:
The following code example shows how to save a multi-page DOCX document as JPEG image with Horizontal layout:
doc = aw.Document(file_name='Rendering.docx')
options = aw.saving.ImageSaveOptions(aw.SaveFormat.JPEG)
# Set up Horizontal layout.
options.page_layout = MultiPageLayout.Horizontal(10);
doc.save(file_name='ImageSaveOptions.GridLayout.jpg', save_options=options)
You can also customize the output file page appearance – specify back_color, border_color, and border_width.
The following code example shows how to save a multi-page DOCX document as PNG image with Grid layout:
doc = aw.Document(file_name='Rendering.docx')
options = aw.saving.ImageSaveOptions(aw.SaveFormat.PNG)
# Set up a grid layout with:
# - 3 columns per row.
# - 10pts spacing between pages (horizontal and vertical).
options.page_layout = aw.saving.MultiPageLayout.grid(3, 10, 10)
# Customize the background and border.
options.page_layout.back_color = aspose.pydrawing.Color.light_gray
options.page_layout.border_color = aspose.pydrawing.Color.blue
options.page_layout.border_width = 2
doc.save(file_name='ImageSaveOptions.GridLayout.png', save_options=options)
Q: How can I export only specific pages of a document to an image?
A: Use the PageSet property of ImageSaveOptions. For example:
options = aw.saving.ImageSaveOptions(aw.SaveFormat.JPEG)
options.page_set = aw.saving.PageSet(ranges=[aw.saving.PageRange(1, 2)]) // export pages 2-3, PageSet has zero-based index
doc.save('SelectedPages.jpg', options)
Q: How do I change the resolution (DPI) of the exported image?
A: Set the vertical_resolution or horizontal_resolution property on ImageSaveOptions. Higher DPI yields larger, higher‑quality images:
options = aw.saving.ImageSaveOptions(aw.SaveFormat.PNG)
options.horizontal_resolution = 72 // 72 DPI
doc.save('HighRes.png', options)
Q: Can I create a multi‑frame TIFF where each page is a separate frame?
A: Yes. Choose the TiffFrames layout and save using the TIFF format:
options = aw.saving.ImageSaveOptions(aw.SaveFormat.TIFF)
options.page_layout = aw.saving.MultiPageLayout.tiff_frames()
doc.save('MultiFrame.tiff', options)
Q: What is the difference between SinglePage and Grid layouts?
A: SinglePage saves only the first page (or the page specified by PageSet). Grid arranges multiple pages in a matrix, letting you define the number of columns and spacing between pages.
Q: How can I customize the background and border of the layout?
A: Use the back_color, border_color, and border_width properties of the page_layout object:
options.page_layout.back_color = aspose.pydrawing.Color.white
options.page_layout.border_color = aspose.pydrawing.Color.black
options.page_layout.border_width = 1
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.