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.
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
| Name | In | Type | Required | Default | |
|---|---|---|---|---|---|
file | body | file | no | The PDF (multipart, raw body with Content-Type application/pdf, or file_base64). | |
url | body|query | string | no | Public URL of the PDF instead of an upload. | |
pages | body|query | string | no | 1 | Pages for JSON output: 1, 1-3,5, 2-, last, all. |
page | body|query | number | no | 1 | The page returned with format=png|jpeg. |
dpi | body|query | number | no | 96 | Resolution, 18-600. |
width | body|query | number | no | Exact image width in pixels (overrides dpi). | |
format | body|query | string | no | json | json, png or jpeg (binary image of one page). |
image_format | body|query | string | no | png | Image type inside the JSON: png or jpeg; quality 10-100 for JPEG. |
text | body|query | boolean | no | false | Also return the text of each page. |
password | body | string | no | Password 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"const form = new FormData();
form.append('file', fileInput.files[0]);
const res = await fetch('https://apibox.io.vn/v1/pdf-render', {
method: 'POST',
headers: { Authorization: 'Bearer YOUR_API_KEY' },
body: form,
});
console.log(await res.json());import requests
res = requests.post(
"https://apibox.io.vn/v1/pdf-render",
headers={"Authorization": "Bearer YOUR_API_KEY"},
files={"file": open("my-file", "rb")},
timeout=30,
)
print(res.json())<?php
$ch = curl_init('https://apibox.io.vn/v1/pdf-render');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => ['Authorization: Bearer YOUR_API_KEY'],
CURLOPT_POSTFIELDS => ['file' => new CURLFile('my-file')],
]);
$response = curl_exec($ch);
print_r(json_decode($response, true));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
Image Metadata & EXIF
Read image dimensions, format, EXIF camera data, capture settings and GPS location from JPEG, PNG, WebP, HEIC, AVIF, GIF and more – upload or URL.
PDFPDF Metadata
Read PDF metadata: page count, title, author, creator, producer, dates, PDF version, encryption, form fields and the size of each page (A4, Letter…).
PDF₫Quote & Receipt PDF
Generate clean PDF quotations, receipts, orders and simple invoices from JSON, with Vietnamese text, VAT, totals in words and a VietQR code for payment.