Generating PDFs
POST /v1/generate turns an HTML document — or a template plus data — into a PDF.
Minimal request
jsonexample
{
"html": "<h1>Hello</h1>"
}All options
jsonexample
{
"html": "<html>...</html>",
"options": {
"format": "A4",
"landscape": false,
"margin": { "top": "20mm", "bottom": "20mm", "left": "15mm", "right": "15mm" },
"header_html": "<div style=\"font-size:10px\">My report</div>",
"footer_html": "<div style=\"font-size:10px\">Page {{page}} of {{pages}}</div>",
"print_background": true,
"scale": 1
}
}Supported formats
| Format | Size |
|---|---|
| A4 | 210 × 297 mm |
| A3 | 297 × 420 mm |
| A5 | 148 × 210 mm |
| Letter | 8.5 × 11 in |
| Legal | 8.5 × 14 in |
| Tabloid | 11 × 17 in |
Page breaks
Use standard CSS. page-break-before, page-break-after, and break-inside: avoid all work.
htmlexample
<section style="page-break-after: always">…page 1…</section>
<section>…page 2…</section>Headers and footers
Header and footer HTML is rendered independently of the body. Use the {{page}} and {{pages}} tokens for pagination.
htmlexample
<div style="font-size:10px; width:100%; text-align:center">
Page {{page}} / {{pages}}
</div>Google Fonts
PDFend automatically detects font-family declarations and injects the corresponding Google Fonts stylesheet if one is not already linked. You can opt out by including your own <link> or setting a custom @font-face.
Response
jsonexample
{
"id": "pdf_abc123",
"status": "completed",
"url": "https://files.pdfend.com/pdf_abc123.pdf",
"pages": 3,
"size": 45230,
"duration_ms": 1180
}File retention
Generated PDFs are stored for 30 days, after which files are deleted and the file url expires. If you need a document for longer, download it and store it on your side — or simply re-generate it from the same HTML or template.