Menu

1 / 4

Same invoice, five JavaScript HTML to PDF libraries: what broke

DEV Community: node·Frank·1 day ago
#gDXLTvyr
#devtonodejs#devto#dev#html#jspdf
Long article (1786 words) — no AI summary yet.
Reading 0:00
15s threshold

Ask how to turn HTML into a PDF in JavaScript and you get five names: Puppeteer, Playwright, jsPDF, html2pdf.js and pdfmake. They get recommended side by side, although they do very different things. So we ran one real document through all five. One of them gave us two blank pages. Another one gave us a PDF that looks right and contains no text.

Disclosure: I'm on the team behind Dynamic Document API, a hosted HTML to PDF API , so we have a horse in this race. That's why everything below is in a public repository and runs in GitHub Actions: the code, the PDFs and the results file.

The test document

An invoice with the things a real one uses today:

a header laid out with Flexbox , with an inline SVG logo

the invoice details (number, dates, PO) in a two-column CSS grid

a web font (Inter, from Google Fonts)

36 line items , so the table runs onto page 2 and should repeat its header row there

totals that shouldn't be split across pages

US Letter, and a footer with the seller on the left and "Page 1 of 2"…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.