Overview
Pages are converted by pdf2htmlEX 0.18.8, which uses Poppler to read the PDF. Every text run becomes an absolutely positioned element in the PDF's own font: embedded fonts are extracted, re-encoded so their characters map to Unicode, and inlined as WOFF web fonts, and fonts the PDF only names are matched to metric-compatible system fonts. Everything that is not text (images, vector paths, shading) is rendered into one PNG background image per page. CSS, fonts and images are all embedded, so the output is a single HTML file with no external references; pages are `div` elements with ids `pf1`, `pf2` and so on, numbered by their position in the PDF.
`pages` takes one page (`3`), a closed range (`2-7`) or an open range (`5-`, to the end); the default is the whole document from page 1. Each call converts at most 10 pages from the start of the range (2 on the Free plan); `nextPage` is the first page left in the requested range, or null, so a loop that sends `pages=<nextPage>-` walks the document. Page numbers past the end return 400 with the page count. The PDF is checked with Poppler's pdfinfo first: an encrypted file without `password` returns 400 "password-protected", a wrong password 400 "not correct". Copy-restriction flags are not enforced.
`textOnly` turns off the background layer, so only positioned text remains; it is much smaller and suits indexing. HTML up to 512 KB is returned in `html` and `inline` is true; larger output has `html` null and is read from `downloadURL`, a signed link valid for two days (`expires`, Unix milliseconds). A conversion has 22 seconds; image-heavy pages that take longer return 504, and a call whose HTML would pass 30 MB returns 413, so convert fewer pages or use textOnly. Scanned PDFs without a text layer come out as background images only.
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/pdftohtml \
-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-"
}'const res = await fetch('https://api.apiverve.com/v1/pdftohtml', {
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-"
}),
});
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/pdftohtml",
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-"
},
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-"
}`)
req, _ := http.NewRequest("POST", "https://api.apiverve.com/v1/pdftohtml", 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 convert (up to 10 MB), or a public PDF URL |
pagesOptional | string | One page or range: 3, 2-7, or 5- for page 5 onwards. Each call converts up to 10 pages (2 on the Free plan) from the start of the range; nextPage says where to continue default 1- · length 0–20 |
passwordOptional | string | User or owner password of an encrypted PDF length 0–256 |
textOnlyOptional | boolean | Leave out images and vector graphics and keep only the positioned text in its fonts |
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": {
"htmlName": "7c1e4b9a-2f3d-4e8a-9b6c-5d0a1f2e3c4b.html",
"pageCount": 14,
"firstPage": 1,
"lastPage": 10,
"pagesConverted": 10,
"nextPage": 11,
"textOnly": false,
"encrypted": false,
"size": 1873402,
"inline": false,
"html": null,
"expires": 1792400000000,
"downloadURL": "https://storage.googleapis.com/apiverve/APIData/pdftohtml/7c1e4b9a-2f3d-4e8a-9b6c-5d0a1f2e3c4b.html?GoogleAccessId=635500398038-compute%40developer.gserviceaccount.com&Expires=1792400000&Signature=SAM…"
}
}
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 |
|---|---|---|---|
htmlName | string | "7c1e4b9a-2f3d-4e8a-9b6c-5d0a1f2e3c4b.html" | File name of the stored HTML |
pageCount | number | 14 | Total pages in the PDF |
firstPage | number | 1 | First page converted |
lastPage | number | 10 | Last page converted |
pagesConverted | number | 10 | Pages in this call's HTML |
nextPage | number | 11 | Page to send next (as pages=<nextPage>-) to continue the requested range, or null when it is done |
textOnly | boolean | false | Whether images and graphics were left out |
encrypted | boolean | false | Whether the PDF was password-protected |
size | number | 1873402 | Size of the HTML in bytes |
inline | boolean | false | Whether the HTML is included in html; false over 512 KB |
html | object | null | The HTML document, or null when it is over 512 KB (use downloadURL) |
expires | number | 1792400000000 | When the download link expires (Unix time in milliseconds) |
downloadURL | string | "https://storage.googleapis.com/apiverve/APIData/pdftohtml/7c1e4b9a-2f3d-4e8a-9b6c-5d0a1f2e3c4b.html?…" | Signed link to download the HTML, 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
- Documents in the Browser
- Show invoices, statements and reports inside your web app as HTML instead of sending users a PDF download.
- Searchable Archives
- Turn PDF archives into HTML pages that search engines and site search can index, with the original look intact.
- Email and CMS Publishing
- Publish brochures, menus and newsletters made as PDFs on a website or in a CMS without retyping them.
- Accessibility Workflows
- Get selectable, copyable text in its original position as a starting point for accessible versions of PDF documents.
Other ways to use PDF to HTML
Set up PDF to HTML 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: