Converting PDF pages to images
Convert each page in a multi-page PDF into a separate image file. Use this approach when you need per-page previews, thumbnails, or image-based processing for individual pages.
Download sampleHow Nutrient supports this workflow
Here’s how the Nutrient Python SDK handles image export for multi-page PDFs.
When you export a multi-page PDF as PNG, JPEG, or BMP, the SDK writes one numbered file for each page. The destination filename acts as a template. For example, output.png becomes output-1.png, output-2.png, and so on.
For TIFF output, the SDK writes all pages to a single multi-page file. If you need single-file TIFF output, refer to the PDF to image guide.
You don’t need to:
- Iterate through pages yourself
- Create per-page filenames
- Render each page to a bitmap before saving
The SDK handles page iteration and file numbering.
Complete implementation
The following example exports each page from a multi-page PDF as a separate PNG file.
Import the required Nutrient classes:
from nutrient_sdk import Documentfrom nutrient_sdk import NutrientExceptionThen open the multi-page PDF and export it as PNG. The SDK detects the output format from the .png extension and writes one file for each page:
def main(): try: with Document.open("input.pdf") as document: document.export_as_image("output.png") print(f"Converted {document.page_count} page(s); see output-1.png, output-2.png, ...") except NutrientException as e: print(f"Error: {e}")
if __name__ == "__main__": main()Output
For a multi-page input PDF, this call writes numbered files like:
output-1.pngoutput-2.png
The original output.png filename serves as the template. The SDK appends -N before the file extension for each page, using one-based numbering.
For single-page documents, the SDK keeps the literal filename unchanged. For that workflow, refer to the PDF to image guide.
Choosing the format
The output behavior depends on the file format you choose.
| Format | Multi-page behavior |
|---|---|
TIFF (.tiff, .tif) | All pages are embedded in one file |
PNG (.png) | One numbered file per page |
JPEG (.jpg, .jpeg) | One numbered file per page |
BMP (.bmp) | One numbered file per page |
To override extension-based format detection, set ImageSettings.ExportFormat before calling export_as_image.
Summary
The overall process matches the single-page workflow. You choose the output format with the file extension, and the SDK exports each page using the appropriate file pattern.
To run the example locally, download the sample package.