The Problem: Quick Document Generation
You need to convert HTML to PDF. Maybe it's a report, a receipt, a proposal, or an export feature. The options aren't great: headless Chrome is heavy (200MB+ memory), wkhtmltopdf is abandoned, and commercial APIs charge $0.01+ per conversion.
We built a free HTML-to-PDF API as part of DocuMint. No signup. No API key. Just send HTML, get a PDF back. Here's how to use it, and what we learned building it.
Quick Start: HTML to PDF in One Request
The simplest possible conversion — send HTML, get PDF:
curl -X POST https://documint.anethoth.com/api/v1/html-to-pdf \
-H "Content-Type: application/json" \
-d '{"html": "<h1>Hello World</h1><p>This is a PDF.</p>"}'
--output document.pdf
That's it. The response is a binary PDF file. No auth token, no account creation, no billing. The endpoint is rate-limited to 30 requests per minute per IP, which is plenty for development and testing.
Custom Page Sizes
Need something other than A4? Pass the page_size parameter:
curl -X POST https://documint.anethoth.com/api/v1/html-to-pdf \
-H "Content-Type: application/json" \
-d '{"html": "<h1>Letter-sized</h1>", "page_size": "Letter"}'
--output letter.pdf
Supported sizes: A4 (default), Letter, Legal, A3, A5. These map to standard CSS @page sizes under the hood.
CSS Styling Works
The HTML you send can include full CSS — inline styles, <style> blocks, even @media print rules:
{
"html": "<style>body{font-family:Georgia,serif;margin:40px}h1{color:#1a1a2e;border-bottom:2px solid #e94560}table{width:100%;border-collapse:collapse}td,th{padding:8px;border:1px solid #ddd}</style><h1>Sales Report Q1</h1><table><tr><th>Month</th><th>Revenue</th></tr><tr><td>January</td><td>$12,400</td></tr><tr><td>February</td><td>$15,800</td></tr><tr><td>March</td><td>$18,200</td></tr></table>"
}
The PDF renderer (WeasyPrint) supports CSS3 including flexbox, grid layout, custom fonts via @font-face, and print-specific properties like page-break-before.
Markdown to PDF
Prefer Markdown? There's a separate endpoint for that:
curl -X POST https://documint.anethoth.com/api/v1/markdown-to-pdf \
-H "Content-Type: application/json" \
-d '{"markdown": "# Project Proposal\n\n## Overview\n\nThis proposal outlines...\n\n## Timeline\n\n| Phase | Duration |\n|-------|----------|\n| Design | 2 weeks |\n| Build | 4 weeks |"}'
--output proposal.pdf
The Markdown endpoint converts to styled HTML internally — proper heading hierarchy, syntax-highlighted code blocks, formatted tables, blockquotes, and lists. The output is a clean, professional-looking document.
Integration Examples
Python
import requests
response = requests.post(
"https://documint.anethoth.com/api/v1/html-to-pdf",
json={"html": "<h1>Invoice #1042</h1><p>Amount: $250.00</p>"},
)
with open("invoice.pdf", "wb") as f:
f.write(response.content)
Node.js
const response = await fetch("https://documint.anethoth.com/api/v1/html-to-pdf", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ html: "<h1>Report</h1><p>Generated at " + new Date().toISOString() + "</p>" }),
});
const pdf = await response.arrayBuffer();
fs.writeFileSync("report.pdf", Buffer.from(pdf));
Go
payload := map[string]string{"html": "<h1>Hello</h1>", "page_size": "Letter"}
body, _ := json.Marshal(payload)
resp, _ := http.Post("https://documint.anethoth.com/api/v1/html-to-pdf",
"application/json", bytes.NewBuffer(body))
defer resp.Body.Close()
pdf, _ := io.ReadAll(resp.Body)
os.WriteFile("output.pdf", pdf, 0644)
Under the Hood: WeasyPrint
The API uses WeasyPrint — a CSS-based PDF rendering engine written in Python. Unlike headless Chrome approaches (Puppeteer, Playwright), WeasyPrint:
- Uses ~50MB of memory vs 200MB+ for Chrome
- Starts instantly (no browser launch overhead)
- Handles CSS3 layout natively without JavaScript execution
- Produces smaller PDF files with proper font embedding
The tradeoff: no JavaScript rendering. If your HTML relies on client-side JS to build the DOM, you'll need to pre-render it. For reports, invoices, receipts, and documentation, WeasyPrint is the better tool.
Limits and Fair Use
- Rate limit: 30 requests/minute per IP
- Max input size: 500KB of HTML
- Branding: Free tier PDFs include a subtle "Generated with DocuMint" footer
- No auth required for the free endpoints
Need higher limits, no branding, and custom invoice templates? DocuMint's paid plans start at $9/month with 500 invoices/month and full API access.
Try It Now
The interactive tool page at documint.anethoth.com/tools/html-to-pdf lets you test the API in your browser — paste HTML, click convert, download the PDF. No signup needed.
Try DocuMint free
A free, no-signup HTML to PDF conversion API. Get started with our free tier — no credit card required.
Get started free →