Overview
Pages are rendered with Poppler, the PDF engine used by most Linux desktops, so text, vector graphics, images and page rotation come out as a PDF viewer shows them. Very large pages are rendered at a lower dpi so no image exceeds 25 megapixels, and each image reports the dpi it was rendered at. Encrypted PDFs are rejected.
Endpoint
One host, one path per API. The block below shows this call in four languages; every one of them is the same HTTP request. Making requests covers the timeouts, retries and parameter rules that apply to all of them. The SDKs wrap the same call in a typed client.
curl -X POST https://api.apiverve.com/v1/pdftoimage \
-H "x-api-key: your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"pdf": "https://raw.githubusercontent.com/mozilla/pdf.js/master/web/compressed.tracemonkey-pldi-09.pdf",
"pages": "1-2",
"format": "png"
}'const res = await fetch('https://api.apiverve.com/v1/pdftoimage', {
method: 'POST',
headers: {
'x-api-key': 'your_api_key_here',
'Content-Type': 'application/json',
},
body: JSON.stringify({
"pdf": "https://raw.githubusercontent.com/mozilla/pdf.js/master/web/compressed.tracemonkey-pldi-09.pdf",
"pages": "1-2",
"format": "png"
}),
});
if (!res.ok) throw new Error(`${res.status} ${await res.text()}`);
const { data } = await res.json();
console.log(data);import requests
res = requests.post(
"https://api.apiverve.com/v1/pdftoimage",
headers={"x-api-key": "your_api_key_here"},
json={
"pdf": "https://raw.githubusercontent.com/mozilla/pdf.js/master/web/compressed.tracemonkey-pldi-09.pdf",
"pages": "1-2",
"format": "png"
},
timeout=15,
)
res.raise_for_status()
print(res.json()["data"])package main
import (
"fmt"
"io"
"net/http"
"strings"
)
func main() {
body := strings.NewReader(`{
"pdf": "https://raw.githubusercontent.com/mozilla/pdf.js/master/web/compressed.tracemonkey-pldi-09.pdf",
"pages": "1-2",
"format": "png"
}`)
req, _ := http.NewRequest("POST", "https://api.apiverve.com/v1/pdftoimage", body)
req.Header.Set("Content-Type", "application/json")
req.Header.Set("x-api-key", "your_api_key_here")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
out, _ := io.ReadAll(res.Body)
fmt.Println(string(out))
}Replace your_api_key_here with the key from your dashboard. When the inputs arrive as a list rather than one at a time, batch requests run up to 200 of them through this same API in a single call.
Authentication
Send your key in the x-api-key header. That is the only auth step — there is no token exchange and no per-endpoint scope to configure. Authentication covers creating, rotating and revoking keys.
A 401 means the key is missing, invalid or expired. A 403 means the key is valid but not permitted here — blocked by a key restriction or an IP allow-list. Running out of credits is a 429.
Parameters
Sent as JSON in the request body. Premium parameters are accepted on every plan but only take effect on plans that include them.
| Parameter | Type | Description |
|---|---|---|
pdfOptional | string | The PDF file to render (up to 10 MB), or a public PDF URL |
pagesOptional | string | Pages to render, as numbers and ranges such as 1-3,5; at most 10 per call on paid plans, 1 on the Free plan default 1 · length 0–100 |
formatOptional | string | Image formatpngjpgjpegdefault png |
qualityOptional | integer | JPG quality from 1 to 100; ignored for PNG default 90 · range 1–100 |
dpiOptionalPremium | integer | Resolution in dots per inch, from 72 to 300 default 150 · range 72–300 |
Response
Every API returns the same three top-level keys, so one response handler covers your whole integration: status, error and data. Only data changes shape. Response format covers the envelope, the other output formats and how premium fields are withheld.
{
"status": "ok",
"error": null,
"data": {
"pageCount": 14,
"format": "png",
"dpi": 150,
"imageCount": 2,
"expires": 1792400000000,
"images": [
{
"page": 1,
"imageName": "3b7e9d21-4c5a-4f80-a1d6-9e2c8b7f5a34-1.png",
"width": 1275,
"height": 1650,
"dpi": 150,
"size": 214533,
"downloadURL": "https://storage.googleapis.com/apiverve/APIData/pdftoimage/3b7e9d21-4c5a-4f80-a1d6-9e2c8b7f5a34-1.png?GoogleAccessId=635500398038-compute%40developer.gserviceaccount.com&Expires=1792400000&Signature=S…"
},
{
"page": 2,
"imageName": "3b7e9d21-4c5a-4f80-a1d6-9e2c8b7f5a34-2.png",
"width": 1275,
"height": 1650,
"dpi": 150,
"size": 198207,
"downloadURL": "https://storage.googleapis.com/apiverve/APIData/pdftoimage/3b7e9d21-4c5a-4f80-a1d6-9e2c8b7f5a34-2.png?GoogleAccessId=635500398038-compute%40developer.gserviceaccount.com&Expires=1792400000&Signature=S…"
}
]
}
}
Response fields
Paths are relative to data. Premium fields are absent rather than zeroed on plans that do not include them, so check for presence instead of comparing to 0.
| Field | Type | Example | Description |
|---|---|---|---|
pageCount | number | 14 | Total pages in the PDF |
format | string | "png" | Image format (png or jpg) |
dpi | number | 150 | Requested resolution in dots per inch |
imageCount | number | 2 | Number of pages rendered |
expires | number | 1792400000000 | When the download links expire (Unix time in milliseconds) |
images | array[2] | One entry per rendered page, in the order requested | |
page | number | 1 | Page number |
imageName | string | "3b7e9d21-4c5a-4f80-a1d6-9e2c8b7f5a34-1.png" | File name of the image |
width | number | 1275 | Image width in pixels |
height | number | 1650 | Image height in pixels |
dpi | number | 150 | Resolution the page was rendered at; lower than requested only for very large pages |
size | number | 214533 | Image size in bytes |
downloadURL | string | "https://storage.googleapis.com/apiverve/APIData/pdftoimage/3b7e9d21-4c5a-4f80-a1d6-9e2c8b7f5a34-1.pn…" | Signed link to download the image, valid for 2 days |
Errors
Read the HTTP status first, then error for the specific reason. The body names the parameter that has to change. Error handling covers the full status list and which of them are worth retrying.
| Status | Meaning | What to do |
|---|---|---|
400 | Input was rejected | Read error; it names the parameter. |
401 | Key missing or invalid | Check the header name and the key value. |
403 | Key valid, but not permitted | A key restriction or IP allow-list; see key scoping. |
429 | Rate limited, or out of credits | Read error to tell them apart; see rate limits. |
Use cases
- Document Thumbnails
- Show a preview image of the first page of uploaded PDFs in file lists and search results.
- Page Previews
- Display individual pages of a contract or report as images where a PDF viewer is not available.
- OCR Pipelines
- Turn scanned PDF pages into images for the Image to Text API or another OCR step.
- Social and Email Images
- Use a page of a brochure, menu or flyer PDF as an image in posts and newsletters.
Other ways to use PDF to Image
Set up PDF to Image on APIVerve, or reach the same source a different way. Your APIVerve account and credits work on all of them — one key, one balance.
Related
More in Documents: