Articles on: Developer

Convert PDFs to Images via API

Sometimes you don't need the PDF itself, but rather a high-quality image of it. Whether you're generating document previews, creating thumbnails, or displaying pages in a web or mobile application, our PDF to Image endpoint makes the conversion simple.


The endpoint supports both single-page and multi-page PDFs. Each converted page is returned as a separate PNG or JPEG image, making it ideal for preview galleries, document viewers, and image processing workflows.


Convert a PDF to Images


You can provide your PDF in two convenient ways:

  • As a public URL
  • As a base64 encoded string


Endpoint Details


HTTP Method: POST
Request URL: https://us1.pdfgeneratorapi.com/api/v4/conversion/pdf2image
Documentation: Official API Docs


Request Body


The example below converts the first four pages of a PDF into PNG images.


{
"file_url": "https://example.org/document.pdf",
"format": "png",
"quality": 85,
"resolution": 150,
"pages": "1-4",
"output": "base64",
"name": "my-document"
}


Field description


Input fields


  • file_url – Public URL to the PDF document. Required if file_base64 is not provided.
  • file_base64 – Base64 encoded PDF. Required if file_url is not provided.


Conversion settings


  • format – Output image format. Supported values are png, jpg, and jpeg (Default: png).
  • quality – Image quality from 1–100 (Default: 85). Higher values produce better image quality, while lower values reduce file size.
  • resolution – Output resolution in DPI from 72–600 (Default: 150). Higher DPI produces sharper images, especially when printing or zooming.
  • pages – Select which pages to convert. You can specify:
    • "all" (default)
    • "1" (single page)
    • "1-4" (page range)


Output settings


  • output – Response format:
    • base64 – Returns the generated images as base64 strings (default).
    • file – Returns downloadable image files.
  • name – Optional output filename (max 120 characters). Auto-generated if not provided.


Response Example


For multi-page PDFs, the response contains an array with one image for each converted page.


{
"response": [
"iVBORw0KGgoAAAANSUhEUgAA..."
],
"meta": {
"name": "document.png",
"display_name": "document",
"encoding": "base64",
"content-type": "image/png"
}
}


Conversion tips


For the best results, choose the settings that match your use case:


  • PNG – Best for document previews, text-heavy pages, screenshots, and graphics.
  • JPEG/JPG – Smaller file sizes, ideal for photographs or when storage and bandwidth are important.
  • 150 DPI – A good balance between quality and performance for most web applications.
  • 300 DPI or higher – Recommended for printing or when users need to zoom into document details.


cURL Example


For a quick test or direct integration, use the following cURL request:


curl --request POST \
--url https://us1.pdfgeneratorapi.com/api/v4/conversion/pdf2image \
--header 'Authorization: Bearer REPLACE_BEARER_TOKEN' \
--header 'content-type: application/json' \
--data '{"file_url":"https://example.org/document.pdf","format":"png","quality":85,"resolution":150,"pages":"1-4","output":"base64","name":"my-document"}'


Updated on: 23/07/2026

Was this article helpful?

Share your feedback

Cancel

Thank you!