PDF development resources
Gathering some options for generating PDFs and pros/cons, in particular for very large PDF reports (100+ pages). Creating such large PDFs in a fast and reliable way is not trivial.
Puppeteerā
- Chromium based. Lots of print features, battle tested.
- Generates large PDF files and is extremely slow (5000 rows takes 2 minutes to generate).
- Can easily crash or run out of memory
react-pdfā
- Kind of supports tables
- Uses
pdfkitinternally - Development is slow, React18 not officially supported
pdfmakeā
Supports tables/multipage, but unstable/beta.
react-to-printā
Render everything in the browser using HTML, and then use browser's print function to print/generate PDF from a subset of the page.
- Slow in Chrome (like Puppeteer)
- Generates huge files (900mb for 5000 rows.)
pdfmeā
Template based. Not suited for multi-page tables.
Low level JS PDF librariesā
These have seemingly no multipage layouts and table support:
- https://github.com/parallax/jsPDF
- https://github.com/foliojs/pdfkit
- https://github.com/Hopding/pdf-lib
html2pdf.jsā
- uses jsPDF
- Con: Renders all content into an image, then places that image into a PDF: This means text is not selectable or searchable, and causes large file sizes.
Alternatives
CSVā
Fast and easy to generate. No layout/styling possibilities.
XLSX exportā
Although XLSX does have layout options, styling is only suported in their Pro version https://sheetjs.com/pro alternatively https://github.com/gitbrent/xlsx-js-style