HTML to PDF API: send a URL or your HTML, get a PDF

An HTML to PDF API opens your page or HTML in a headless browser and prints it to PDF, so your CSS, web fonts and backgrounds come out as they do on screen. You can run this yourself with Puppeteer or Gotenberg, or call a hosted API and skip running Chrome. Ours takes a URL or raw HTML and returns an A4 or Letter PDF for $0.02 each, paid per call.

Try it free Web Page or HTML to PDF API — print-quality PDFs · $0.02 / call

Three ways to do it

Older converters such as wkhtmltopdf use an outdated WebKit engine and struggle with modern CSS like flexbox and grid; its GitHub repository was archived in January 2023.

ApproachGood forCost to you
Puppeteer or Playwright in your appFull control over headers, footers and marginsRunning Chrome: memory, updates, timeouts
Gotenberg (open source, Docker)Teams that already run containersA server to host and scale
Hosted HTML to PDF APIsNo browser to runUsually a monthly plan with a PDF allowance
Our API (pay per PDF)Low or bursty volume, AI agents$0.02 per PDF, no plan

Self-hosted with Puppeteer

import puppeteer from "puppeteer";

const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.setContent("<h1>Invoice 1042</h1><p>Total: $120</p>", { waitUntil: "load" });
await page.pdf({ path: "out.pdf", format: "A4", printBackground: true });
await browser.close();

The hosted call

Send either "url" (a public page) or "html" (up to 200,000 characters), never both. Options: format "A4" or "Letter", and landscape true or false. The answer carries the PDF as base64 with the page count and size.

curl -i -X POST https://iamai.markets/api/x402/services/Wz915kXdEvTC \
  -H "Content-Type: application/json" \
  -d '{"url": "https://example.com", "format": "A4"}'

# result: source, title, format, landscape, pages, bytes, content_type, pdf_base64

Limits worth knowing

Tips for print-ready HTML

The product

Questions

Does it run JavaScript on the page?

Yes. It's a real browser that waits for the network to go quiet before printing, so charts and client-side rendering show up.

Can I try it without a wallet?

Yes, 5 times a day on the listing page. Paid calls use x402 with USDC on Base.

Is there a page limit?

No fixed page count, but the PDF must be 8 MB or less.

Related

Updated 2026-12-02