render-bolt
Dashboard

PDF

POST /v1/pdf prints a URL or your HTML to PDF, with page sizes, margins, headers and footers with page numbers.

POST https://rendersbolt.com/v1/pdf
GET  https://rendersbolt.com/v1/pdf?url=...&access_key=...

Returns application/pdf. Backgrounds and colors are printed by default. Send either url or html.

Example#

curl https://rendersbolt.com/v1/pdf \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"html":"<h1>Invoice #1042</h1><p>Total: €120.00</p>","format":"A4","margin":"15mm"}' \
  -o invoice.pdf
const res = await fetch('https://rendersbolt.com/v1/pdf', {
  method: 'POST',
  headers: { Authorization: `Bearer ${process.env.API_KEY}`, 'Content-Type': 'application/json' },
  body: JSON.stringify({ html: invoiceHtml, format: 'A4', margin: '15mm' }),
});
const pdf = Buffer.from(await res.arrayBuffer());
r = requests.post(
    "https://rendersbolt.com/v1/pdf",
    headers={"Authorization": f"Bearer {os.environ['API_KEY']}"},
    json={"html": invoice_html, "format": "A4", "margin": "15mm"},
)
pdf = r.content

Parameters#

PDF-specific options below. Every common option works too.

Parameter Default Description
url or html The page to print. html can be up to 5 MB.
format A4 A0–A6, Letter, Legal, Tabloid, Ledger
width, height Custom size such as "80mm", used instead of format (receipts, labels)
landscape false
print_background true Print CSS backgrounds and colors
margin "15mm" for all sides, or {"top":"20mm","bottom":"20mm","left":"10mm","right":"10mm"}. Units: mm, cm, in, px.
header_template, footer_template HTML printed on every page. See below.
scale 1 0.1–2
page_ranges For example "1-3, 5"
prefer_css_page_size false Use @page { size } from your CSS
emulate_media print screen prints the page as it looks on screen
response_type binary binary, url or base64, as for screenshots

Headers and footers#

Elements with these classes are filled in on every page: pageNumber, totalPages, date, title, url.

{
  "html": "...",
  "margin": { "top": "20mm", "bottom": "20mm", "left": "12mm", "right": "12mm" },
  "footer_template": "<div style='font-size:9px;width:100%;text-align:center'>Page <span class='pageNumber'></span> of <span class='totalPages'></span></div>"
}

Tip

Templates are printed inside the margin, so leave room for them. If you send a template and no margin, a 20 mm top and bottom margin is used. Templates don't see your page's CSS: use inline styles and always set a font-size. Images inside templates must be data: URIs.

Responses#

With the default response_type, the body is the PDF. With url or base64 the JSON also includes pages, the page count.

Related guide: Invoices, receipts and reports.

Stuck? Write to [email protected] with the request you sent and the error code you got back.

Get your free API key

100 renders a month with every feature. No card needed.