r/learnjavascript • u/ExcellentEducator960 • May 08 '26
Best approach for professional invoice PDF generation?
I’m trying to build a custom invoice PDF system similar to Tally invoices and struggling with dynamic table layouts.
I tested pdfmake, but faced issues like:
- text overflow
- inconsistent row heights
- messy page breaks
- table/layout breaking with large data
Then I checked iText, but even there people mention overflow/layout limitations with dynamic content.
So how do professional systems like Tally actually generate reliable invoices?
Do most developers use:
- HTML/CSS + Puppeteer
- iText/PDFBox
- reporting tools
- or something else?
Main goal:
A4 printable invoices with preview + download and stable dynamic tables.
3
u/opentabs-dev May 08 '26
html/css + a headless chrome renderer is what most production invoice systems end up doing, honestly. puppeteer or playwright, and then chromium handles all the table reflow, page breaks, and overflow logic for you — way less painful than trying to fight pdfmake's layout engine. key css tricks:
page-break-inside: avoidon table rows,display: table-header-groupon the thead so it repeats on every page, and@page { size: A4; margin: ...}for sizing. if you don't want to bundle chromium, gotenberg is a nice little docker service that takes html and gives you pdf back.2
u/PropertyZestyclose49 May 14 '26
I'd go with HTML/CSS + a headless Chrome renderer for this. For invoices with dynamic tables, page breaks, repeated headers, A4 sizing, and preview/download, it is usually much easier than fighting pdfmake or iText layout issues.
One tip: build the invoice as an A4 HTML page first, then use print CSS for the PDF output. That way your preview and generated PDF stay very close.
I'm the founder of CraftMyPDF. We built it for this kind of use case: professional invoice PDFs, dynamic tables, page breaks, reusable templates, and API-based PDF generation. Other than using code, CraftMyPDF also has a drag and drop editor, so you can design the invoice visually and send JSON data to generate PDFs.
If you are specifically looking for HTML to PDF, I would suggest APITemplate instead.
Happy to help if you need any pointers.
2
u/[deleted] May 08 '26
[removed] — view removed comment
2
u/[deleted] May 08 '26
[removed] — view removed comment