Skip to content

Guide

Generate invoice PDFs from existing HTML

Use your existing invoice HTML and CSS to create PDFs with print backgrounds, page numbers, headers and footers.

If an invoice already has an HTML web view, the same markup and styles can be used for the PDF. This keeps the browser and PDF versions aligned without maintaining a separate layout.

Ironfang Render uses Chromium to apply browser layout and print styles before returning the finished PDF.

Create the PDF

curl -X POST https://api.ironfang.uk/renderwolf/v1/pdf \
  -H "Authorization: Bearer if_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "html": "<h1>Invoice INV-1042</h1>...",
    "print_background": true,
    "footer_html": "<div style=\"font-size:9px;width:100%;text-align:center;color:#666\">Page <span class=\"pageNumber\"></span> of <span class=\"totalPages\"></span></div>"
  }' \
  --output invoice-1042.pdf

Configure backgrounds, headers and footers

Set print_background to true to retain background colours and images that browsers omit from printed output by default. This is useful for invoices with branded headers or highlighted totals.

Chrome provides the pageNumber, totalPages, date, title and url classes inside header and footer templates. Use these classes to add accurate page details to each PDF.

Credit usage

Each PDF uses two credits. Identical cached requests use zero credits, so retrieving the same invoice again does not reduce your allowance.

Next