PPDFInvoiceAPI
DOCS/ Rendering HTML

CORE

Rendering HTML

The simplest way to render: pass a self-contained HTML string and get the PDF back.

The html field

Send your markup as the html field. It's rendered exactly as a browser would render it, then printed to PDF — so anything that works in Chrome works here.

{
  "html": "<!doctype html><html><head><style>body{font-family:system-ui;padding:40px}h1{color:#5b3df5}</style></head><body><h1>Invoice #1024</h1><p>Total: €1,240.00</p></body></html>",
  "pdf": { "format": "A4", "printBackground": true }
}

Provide either html or atemplate (with data) — not both. Ifhtml is present, template and data are ignored. To merge dynamic values, usetemplates instead.

Styling & assets

  • Inline your CSS in a <style> tag (or use inline styles). External stylesheets work if they're reachable over HTTPS, but inlining is faster and more reliable.
  • Images should be absolute https:// URLs ordata: URIs. Embedding small assets as base64data: URIs avoids an extra fetch.
  • Fonts load from Google Fonts or any HTTPS source via@font-face; data:-embedded fonts are the most reliable.
  • Set printBackground: true inPDF options so background colors and images show up (it's on by default).

Page breaks

Use standard CSS print rules to control pagination:page-break-after: always to force a new page, andbreak-inside: avoid on rows or cards to keep them intact across pages. The renderer covers documents up to roughly 30 pages comfortably; for very large jobs see Async & large documents.