Document-to-image API
The document-to-image API converts Office documents into images with configurable dimensions and quality settings. Supported input formats include DOC, DOCX, XLS, XLSX, PPT, PPTX, and HTML. Supported output formats are JPG, PNG, WebP, and TIFF. The examples below use JPG, but you can change the format value to match your desired output format.
Rendering a single page
By default, the first page is rendered. Render any other page by adding the pages option.
The example below renders the fifth page. Note that pages are indexed starting from zero:
"output": { "type": "image", "pages": {"start": 4, "end": 4}, "format": "jpg", "width": 500}Rendering multiple pages
In addition to rendering a single page (the default), it’s possible to render multiple pages at the same time by adding the pages option.
Render up to 50 pages in a single request. Requesting more than 50 pages results in a status
400being returned.
The following example returns a ZIP file containing all pages:
"output": { "type": "image", "pages": {"start": 0, "end": -1}, "format": "jpg", "width": 500}Render a subset of pages by specifying a range. The example below renders pages two, three, and four:
"output": { "type": "image", "pages": {"start": 1, "end": 3}, "format": "jpg", "width": 500}Files in the ZIP archive are named <page_number>.<format> (e.g. 1.jpg, 1.png).
Controlling image dimensions
Specify either a width, height, or resolution for output images — choose only one option. Specifying more than one results in a status 400 being returned.
Depending on which option you choose, one or both dimensions are determined based on the page dimensions in the document.
The maximum image resolution is 34 million pixels (4960×7016px), regardless of aspect ratio. Requesting a larger image results in a status
400being returned.
Specify the width option to render all pages with the same width and varying heights based on page dimensions:
"output": { "type": "image", "format": "jpg", "width": 768}Specify the height option to render all pages with the same height and varying widths based on page dimensions:
"output": { "type": "image", "format": "jpg", "height": 1024}Specify the dpi option to render pages where width and height depend only on page dimensions:
"output": { "type": "image", "format": "jpg", "dpi": 72}