PDF from HTML API - Build Print-Ready HTML for PDF Export
Accepts an HTML string and optional format (A4 or letter) and landscape flag. Returns a complete HTML document with @page size rules and baseline print styles (margins, headings, paragraphs, blockquotes, code, images). Open the returned HTML in a browser or headless Chromium and use File > Print > Save as PDF to produce the actual PDF file.
Code examples
curl -X POST https://api.botoi.com/v1/pdf/from-html \
-H "Content-Type: application/json" \
-d '{"html":"<h1>Invoice #1042</h1><p>Amount due: $249</p>","options":{"format":"letter","landscape":false}}'When to use this API
Invoice and receipt generation
Render an invoice template from your data as HTML, wrap it for print with this endpoint, then rasterize via headless Chromium on your backend. The @page rules ensure margins and paper size are correct.
Report export from dashboards
Let users export a dashboard snapshot as PDF. Grab the rendered HTML, call this endpoint, and stream the wrapped document through Puppeteer to generate the final PDF.
Printable documentation
Convert docs pages to print-ready PDFs. The wrapper styles headings, code blocks, and images with sensible defaults so the output looks professional without custom CSS.
Frequently asked questions
Why doesn't this return a PDF directly?
What formats are supported?
Are the baseline styles overridable?
What about custom fonts?
How do I generate the PDF in Node.js?
Get your API key
Free tier includes 5 requests per minute with no credit card required. Upgrade for higher limits.