Skip to content

HTML to PDF API

HTML to PDF API for production documents

Generate statements, reports, contracts and certificates from the HTML and CSS your application already renders. One request in, a finished document back, with the paper size, margins and repeating furniture you set.

Create a free accountRead the API docs

  • Two credits per PDF
  • Six paper formats
  • Refunds on failed work
  • UK-operated infrastructure
A4
Page 1 of 3

One request

You already built this document once

Most PDF libraries ask you to rebuild a layout you have already written in HTML and CSS, in a drawing API with its own units, fonts and box model. The document on screen and the document in the attachment then drift apart, and every change costs twice.

Ironfang Render prints the markup you already have, in a real browser, with the paper size, margins, scale and repeating header and footer set per request. One template, two outputs, one place to change it.

POST /render/v1/pdf
Authorization: Bearer if_live_...
Content-Type: application/json

{
  "html": "<html>...your document...</html>",
  "paper_format": "a4",
  "print_background": true,
  "margin": { "top": 0.6, "bottom": 0.8 },
  "header_html": "<span></span>",
  "footer_html": "<p style='font-size:9px'>Page <span class='pageNumber'></span></p>"
}

200 OK
Content-Type: application/pdf

Capabilities

Document controls, as request parameters

The print settings you would otherwise chase through a browser dialogue, set per request and identical every time.

Your HTML and CSS

Print the markup your application already produces. No PDF-specific layout library, no second implementation of a document you have already built once.

Six paper formats

A3, A4, A5, Letter, Legal and Tabloid, portrait or landscape, with margins and a scale factor set per request.

Repeating headers and footers

Supply header and footer HTML and it appears on every page, which is where page numbers, logos and document references belong.

Backgrounds that survive printing

Turn on print backgrounds and your tints, panels and brand colours come through instead of being dropped the way a browser drops them.

Documents behind a login

The same headers, Authorization header and cookies as a screenshot request, so an authenticated statement prints as easily as a public page.

Direct binary response

The PDF comes back in the response. No job to poll, no bucket to read from, unless you want the asynchronous path for long documents.

Use cases

Documents worth generating rather than designing twice

Anywhere your application already renders the content and somebody needs it as a file.

Statements and remittances

Period statements and remittance advice, rendered from the same template your account screens already use.

Order confirmations

Attach a printable confirmation to the email your application already sends, produced from one request.

Reports and exports

Turn a dashboard or a report page into a document somebody can file, print or forward.

Certificates and passes

Personalise per recipient with variables, and composite a verified QR code into the layout.

Contracts and letters

Produce consistent, branded documents from HTML rather than from a word processor template nobody owns.

Printable dashboards

Print an authenticated view on a schedule so the weekly pack builds itself.

A complete request, and what it returns

Send the HTML, or a url instead, to POST /render/v1/pdf with your API key. A success is 200 with Content-Type: application/pdf and the document as the body. Anything else is JSON, {"error": {"code", "message"}}, so check the status before saving the body as a PDF. This renders the invoice template from the guide:

curl -sS https://api.ironfang.com/render/v1/pdf \
  -H "Authorization: Bearer $IRONFANG_API_KEY" \
  -H "Content-Type: application/json" \
  --data-binary @request.json \
  -o invoice.pdf \
  -w '%{http_code} %{content_type}\n'

200 application/pdf means invoice.pdf is the invoice. Download request.json, the HTML template it was built from, or the PDF it produces.

What to know before you integrate

  • Paper: A3, A4, A5, Letter, Legal and Tabloid, portrait or landscape. Without a paper format the page is Letter, and the requested format wins over a stylesheet's @page size.
  • Margins are in inches, per side. Headers and footers draw inside the margins, so leave room for them.
  • Sending only a footer makes Chromium print its default date and title header; send "header_html": "<span></span>" with it.
  • Backgrounds are left out unless print_background is true.
  • Fonts are the renderer's own: load any other with @font-face from a public URL or data URI. Images and stylesheets must be reachable from the public internet.
  • Page breaks follow CSS: break-inside: avoid keeps a row or block whole, and a table's thead repeats on each page.
  • PDFs are never cached, and signed URLs do not serve PDFs. Keep the documents you issue; a batch job can deliver them to your own S3 bucket.
  • A render stops after 30 seconds; a failed render is refunded.

Try it free in the browserPython example

Page 1 of the PDF this request returns: invoice INV-1042 from Northwind Studio Ltd, six line items and a total due of 13,410.00 pounds.
The first page of invoice.pdf, from the invoice template guide.

Generating invoices?

A billing run needs more than one rendered document: thousands of them on the first of the month, an archived copy you own, and a download link a customer can use without your application streaming the bytes. That has its own page, and the invoice PDF guide has a complete invoice template, the request that renders it and the PDF it produces.

Invoice PDF APIPDF request reference

Pricing

Two credits per PDF, with failures refunded

Start with 250 free credits each month and no card required. Paid plans begin at £9 per month for 5,000 credits, shared across screenshots, PDFs, images and video. Failed work is refunded, and reaching a cap pauses rendering rather than billing overage.

See Ironfang Render pricingCompare with other providers

Questions

Before you integrate

The details that decide whether this fits, without reading the whole reference first.

Can I send HTML directly instead of a URL?
Yes, and it is the common case. Send the HTML your application already renders and it is printed as-is, so the document you can see in your own application is the document that arrives as a file.
Which paper sizes are supported?
A3, A4, A5, Letter, Legal and Tabloid, in portrait or landscape, with margins in inches for each side and a scale factor you set per request.
Can I put a header and footer on every page?
Yes. Supply header and footer HTML and it repeats on each page, which is where page numbers, a logo or a document reference usually belong.
Why are my background colours missing?
Browsers do not print backgrounds by default. Turn print backgrounds on in the request and your CSS colours, tints and panels come through.
Does the page need to be public?
No. A PDF request takes the same custom headers, Authorization header and cookies as a screenshot, so a document behind a login prints the same way.
What does a PDF cost?
Two credits per PDF, against one for a screenshot. Every PDF request renders the document afresh, failed work is refunded, and reaching a cap pauses rendering rather than billing overage.
Can I include a QR code in the document?
Yes. Generate the code with the QR endpoint, which is free on every plan and checks that the code scans before returning it, then place it in your HTML as an image. It prints as part of the layout like any other image.

Less to operate. More to ship.

Generate your first document

Create an account, take a key and send your existing HTML. The first PDF is inside your free credits.

250 free credits each month, with no card required, hard usage caps and refunds on failed work.