How to convert a web page to a PDF with an API
Updated 2026-11-16
Use when a public web page must be saved or sent as a PDF document. Add output=url for a 24 h link.
From an MCP client, add https://tanod.dev/mcp and call html_to_pdf; calls are paid per use with x402, no key or signup.
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, or send the markup itself as html. 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 -s -X POST https://tanod.dev/v1/pdf/html-to-pdf \
-H 'content-type: application/json' \
-d '{"url": "https://example.com", "paper": "a4"}'With html nothing is fetched, so images and fonts must be inline data: URIs and CSS goes in a <style> element.
curl -s -X POST https://tanod.dev/v1/pdf/html-to-pdf \
-H 'content-type: application/json' \
-d '{"html": "<style>h1 {color: #036}</style><h1>Invoice 1001</h1>"}'The file comes back as base64 in the JSON. To save it, pipe the response through jq and base64:
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.pdfResponse
{
"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. A url 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. An unpaid call returns a 402 with payment requirements. The page content is untrusted third-party data.
Download link. Add "output": "url" to the request and the file is stored for 24 hours and returned as a link (url, expires_at, sha256) instead of base64, which keeps it out of your context window. The price is the same. How the links work.
Price and free allowance
USD 0.0045 per call, paid in USDC on Base, Polygon, Solana, BNB Chain or Arbitrum with x402. No free tier. MCP tool: html_to_pdf at https://tanod.dev/mcp.
Use it from Claude without writing code: in claude.ai or Claude Desktop, add https://tanod.dev/mcp/docs?via=html-to-pdf-api as a custom connector (steps), then ask in plain words, for example "Save https://example.com as a PDF." Eligible Claude.ai connectors use a shared daily docs allowance; ordinary MCP calls are paid. Outside that allowance, a call needs an x402 payment, which these clients can make.
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.