# PDF to HTML API

> PDF to HTML converts the pages of a PDF, uploaded or fetched from a URL, into one self-contained HTML file that looks like the original: same layout, embedded fonts and images, and real selectable text. Choose a page range, unlock password-protected PDFs, or ask for text only; long documents are converted in batches, with nextPage pointing to the next one.

**Endpoint:** `POST https://api.apiverve.com/v1/pdftohtml`  
**Category:** Documents  
**Cost:** 20 credits per call  
**Canonical page:** https://apiverve.com/marketplace/pdftohtml

## Overview

Conversion uses pdf2htmlEX, which places every line of text where it sits in the PDF using the PDF's own fonts, converted to web fonts and embedded in the file, and draws images and vector graphics as a background layer. The HTML needs no other files, so it can be stored, emailed or shown in an iframe as it is.

Paid plans convert up to 10 pages per call and the Free plan 2; pageCount gives the length of the document and nextPage the page to send next. textOnly leaves out the background layer for smaller files that keep just the positioned text. HTML up to 512 KB is returned in the response; every result is also stored behind a download link valid for 2 days.

## Authentication

Every call carries your key in an `x-api-key` header. The same key works across the whole
APIVerve catalog — there are no per-API subscriptions. Responses always use the same three
top-level keys: `status`, `error`, and `data`.

## Example request

```bash
curl -X POST "https://api.apiverve.com/v1/pdftohtml" \
  -H "x-api-key: YOUR_API_KEY" \
  -F "pdf=@document.pdf" \
  -F "pages=1-" \
  -F "textOnly=false"
```

## Parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `pdf` | string | No | The PDF file to convert (up to 10 MB), or a public PDF URL |
| `pages` | string | No | 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 |
| `password` | string | No | User or owner password of an encrypted PDF. length 0-256 |
| `textOnly` | boolean | No | Leave out images and vector graphics and keep only the positioned text in its fonts. default false |

## Response fields

- `htmlName` — string · File name of the stored HTML
- `pageCount` — number · Total pages in the PDF
- `firstPage` — number · First page converted
- `lastPage` — number · Last page converted
- `pagesConverted` — number · Pages in this call's HTML
- `nextPage` — number · Page to send next (as pages=<nextPage>-) to continue the requested range, or null when it is done
- `textOnly` — boolean · Whether images and graphics were left out
- `encrypted` — boolean · Whether the PDF was password-protected
- `size` — number · Size of the HTML in bytes
- `inline` — boolean · Whether the HTML is included in html; false over 512 KB
- `html` — object · The HTML document, or null when it is over 512 KB (use downloadURL)
- `expires` — number · When the download link expires (Unix time in milliseconds)
- `downloadURL` — string · Signed link to download the HTML, valid for 2 days

## Sample response

```json
{
  "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=SAMPLE"
  }
}
```

## 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.

## More

- Full reference: https://docs.apiverve.com/ref/pdftohtml
- Get an API key: https://dashboard.apiverve.com
- Full catalog: https://apiverve.com/marketplace
