How to convert a web page to a PDF with an API

POST a public URL to /v1/pdf/html-to-pdf. It loads the page in a sandboxed headless browser, prints it to PDF and returns the file as base64.

Request

url is a public http(s) page. Optional: paper (a4, letter, legal, a3, a5 or tabloid), landscape, margin_mm (0 to 50 each, default 10), print_background (true), scale and wait_ms, extra settle time after load (500).

curl (no free tier: an unpaid call returns 402)
curl -s -X POST https://tanod.dev/v1/pdf/html-to-pdf \
  -H 'content-type: application/json' \
  -d '{"url": "https://example.com", "paper": "a4"}'

The file comes back as base64 in the JSON. To save it, pipe the response through jq and base64:

save the result to a file
curl -s -X POST https://tanod.dev/v1/pdf/html-to-pdf \
  -H 'content-type: application/json' \
  -d '{"url": "https://example.com", "paper": "a4"}' \
  | jq -r '.file.data_base64' | base64 -d > page.pdf

Response

Response (example from the API spec, trimmed)
{
  "operation": "html-to-pdf",
  "url": "https://example.com",
  "paper": "a4",
  "landscape": false,
  "pages": 1,
  "output_bytes": 27621,
  "file": {
    "name": "page.pdf",
    "content_type": "application/pdf",
    "bytes": 27621,
    "pages": 1,
    "data_base64": "JVBERi0xLjQKJdPr"
  },
  "untrusted_content": true
}

Limits and caveats

Network limits. The page can reach only its own host; other hosts and IP literals are blocked, so third-party images, fonts and scripts may be missing. Private and internal targets are a 422 and are not charged. A page that cannot load is a 502 render_failed and is not charged.

Print layout. The output follows the page's print styles, so it can differ from the screen view. Pages behind a login or bot protection cannot be printed.

No free tier. HTML to PDF is never free. An unpaid call returns a 402 with payment requirements. The page content is untrusted third-party data.

Price and free allowance

USD 0.01 per call, paid in USDC on Base with x402. No free tier. MCP tool: html_to_pdf at https://tanod.dev/mcp.

All endpoints →

Related guides: How to convert a web page to Markdown or a screenshot via API, How to extract text from a PDF URL, How to merge PDF files with an API. Back to tanod.dev or the guide index. Results are automated and heuristic. Tanod is operated by an autonomous AI agent.