PDF to Image (render pages) API

Render PDF pages to PNG or JPEG with PDFium: choose pages, DPI or width, get thumbnails, previews and the page text. Upload or URL.

GETPOSThttps://apibox.io.vn/v1/pdf-render

Upload a PDF (multipart file, raw body with Content-Type: application/pdf, file_base64) or give its url, pick the pages (1, 1-3,5, last, all) and the resolution (dpi, default 96, or an exact pixel width, or scale), and get each page as PNG or JPEG. The default JSON answer lists every page with its pixel and point size and the image as a data URI; format=png or format=jpeg returns the image of one page directly, handy for <img src> previews and chat bots.

Rendering uses PDFium, the PDF engine of Chrome (BSD / Apache-2.0, via @hyzyla/pdfium, MIT) compiled to WebAssembly and running in a separate APIBox Worker; standard PDF fonts are built in, form fields are drawn, encrypted files open with password. text=true also returns the text of each page. transparent=true keeps the page background transparent (PNG).

Limits: PDF up to 20 MB (5 MB on the free plan), 20 pages per request (5 on Free), 12 megapixels per page and 30 MP per request: lower dpi or width for big pages.

Markdown · OpenAPI · Postman · llms.txt

Parameters

NameInTypeRequiredDefault
filebodyfilenoThe PDF (multipart, raw body with Content-Type application/pdf, or file_base64).
urlbody|querystringnoPublic URL of the PDF instead of an upload.
pagesbody|querystringno1Pages for JSON output: 1, 1-3,5, 2-, last, all.
pagebody|querynumberno1The page returned with format=png|jpeg.
dpibody|querynumberno96Resolution, 18-600.
widthbody|querynumbernoExact image width in pixels (overrides dpi).
formatbody|querystringnojsonjson, png or jpeg (binary image of one page).
image_formatbody|querystringnopngImage type inside the JSON: png or jpeg; quality 10-100 for JPEG.
textbody|querybooleannofalseAlso return the text of each page.
passwordbodystringnoPassword of an encrypted PDF.

Example

curl -X POST "https://apibox.io.vn/v1/pdf-render" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -F "file=@./my-file"

Response

{
  "source": "upload",
  "page_count": 3,
  "image_format": "png",
  "scale": 1,
  "pages": [
    {
      "page": 1,
      "width": 595,
      "height": 842,
      "width_pt": 595,
      "height_pt": 842,
      "bytes": 8794,
      "text": "Trang 1 - Hoá đơn giá trị gia tăng",
      "image": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAlMAAANKCAIAAA…"
    }
  ]
}

Use cases

  • Show a thumbnail of uploaded invoices or contracts in your app
  • Send a page preview of a PDF to Zalo / Telegram bots
  • Make Open Graph images of PDF documents
  • Turn exam papers or catalogues into images for a web viewer

FAQ

What resolution should I use?

dpi=96 for screens, 150 for crisp previews, 300 for print. Or set width (pixels) to get a fixed-width thumbnail.

Can it render scanned PDFs?

Yes, scanned pages are images inside the PDF and render like any page. Use ocr on the result if you need the text.

Is WebP available?

Not yet: PNG (lossless) and JPEG (quality 10-100) are returned.

Related APIs

Start with 1,000 free requests every month. Get free API key →