FrameForge › Guides › HTML to PDF in curl / Bash

HTML to PDF in curl / Bash

Send HTML (or a URL) to the FrameForge API and get a PDF back. It is rendered in real Chromium, so modern CSS, web fonts and JavaScript all work. No browser to install or babysit.

The code

Any shell with curl. Set FRAMEFORGE_KEY to your API key.

curl -sS -X POST https://api.frameforgeapi.com/render \
  -H "X-API-Key: $FRAMEFORGE_KEY" \
  -H "Content-Type: application/json" \
  -d '{"html":"<h1>Invoice #1001</h1><p>Total: £49.00</p>","format":"pdf","width":794,"height":1123}' \
  --fail-with-body --output invoice.pdf

How it works

Rendering a URL instead of HTML

{"url": "https://example.com/report", "format": "pdf", "width": 1280, "height": 800, "fullPage": true}

Doing it yourself instead

Chrome itself can print from the command line (google-chrome --headless --print-to-pdf=out.pdf URL). That is handy for one-offs, but you manage the browser install and fonts on every machine.

An API makes sense when you don't want Chromium on your servers, or when you need images (PNG/JPEG) and PDFs from the same call. If you render a few PDFs a month on a server you already run, self-hosting is perfectly reasonable.

Free tool: Website to PDF. Other languages: Node.js · Python · PHP · Ruby · Go · Java · C# / .NET · Next.js · Laravel · Django · Ruby on Rails