Docs/APIs/PDF to HTML

PDF to HTML

Convert PDF pages to HTML that looks like the PDF

OperationalCredits 20 per callp50 3080msDocumentsStar

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.

Live Test PDF to HTML API →

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.

POSThttps://api.apiverve.com/v1/pdftohtml
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-"
}'

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.

401 is the only auth verdict

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.

ParameterTypeDescription
pdfOptionalstringThe PDF file to convert (up to 10 MB), or a public PDF URL
pagesOptionalstringOne 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
passwordOptionalstringUser or owner password of an encrypted PDF
length 0–256
textOnlyOptionalbooleanLeave 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.

Sample response
{
  "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.

FieldTypeExampleDescription
htmlNamestring"7c1e4b9a-2f3d-4e8a-9b6c-5d0a1f2e3c4b.html"File name of the stored HTML
pageCountnumber14Total pages in the PDF
firstPagenumber1First page converted
lastPagenumber10Last page converted
pagesConvertednumber10Pages in this call's HTML
nextPagenumber11Page to send next (as pages=<nextPage>-) to continue the requested range, or null when it is done
textOnlybooleanfalseWhether images and graphics were left out
encryptedbooleanfalseWhether the PDF was password-protected
sizenumber1873402Size of the HTML in bytes
inlinebooleanfalseWhether the HTML is included in html; false over 512 KB
htmlobjectnullThe HTML document, or null when it is over 512 KB (use downloadURL)
expiresnumber1792400000000When the download link expires (Unix time in milliseconds)
downloadURLstring"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.

StatusMeaningWhat to do
400Input was rejectedRead error; it names the parameter.
401Key missing or invalidCheck the header name and the key value.
403Key valid, but not permittedA key restriction or IP allow-list; see key scoping.
429Rate limited, or out of creditsRead 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.

Give it to an AI agentConnect over MCP and your agent calls it as a native tool — Claude, Cursor, ChatGPT.VerveKit →Reference →

More in Documents:

Was this page helpful?