JavaScript libraries (PDFKit, jsPDF, pdfmake, React-PDF, pdf-lib)
By Jason Galea · Part of the How to create a PDF benchmark
Takeaway: JavaScript PDF libraries run directly in Node or the browser with no external service, but every library we tested dropped CJK and colour emoji out of the box, and four of five emitted no accessibility tags at all.
| Sample PDF | Size | Pages | Tagged | PDF/UA-1 | PDF/A-2a | Zürich / 東京 / 🚀 | Fig alt | Table tags |
|---|---|---|---|---|---|---|---|---|
| pdfkit-default | 31 KB | 2 | no | fail (12r / 515c) | fail (7r / 1229c) | ✓ ✗ ✗ | ✗ | ✗ |
| pdfkit-pdfua | 34 KB | 2 | yes | fail (6r / 11c) | fail (8r / 1232c) | ✓ ✗ ✗ | ✓ | ✗ |
| jspdf | 782 KB | 2 | no | fail (9r / 331c) | fail (6r / 965c) | ✓ ✗ ✗ | ✗ | ✗ |
| pdfmake | 34 KB | 2 | no | fail (11r / 1046c) | fail (6r / 2424c) | ✓ ✗ ✗ | ✗ | ✗ |
| react-pdf | 33 KB | 2 | no | fail (11r / 243c) | fail (7r / 699c) | ✓ ✗ ✗ | ✗ | ✗ |
Checked with veraPDF 1.28.2 (r = failed rules, c = failed checks). Click any sample name to download the PDF, or test your own output in /validate (free, no sign-in) and inspect structure trees in /tags.
If you are already in Node.js or React, pulling in an npm package to generate PDFs directly in-process is an appealing idea: no browser container, no external API, and everything stays in one codebase.
We rebuilt the shared Quarterly Field Report using each library's native API across PDFKit 0.21.0, jsPDF 4.2.1 (with jspdf-autotable), pdfmake 0.3.15 and @react-pdf/renderer 4.9.2.
What stood out across all of them
Two gaps showed up in every single JavaScript library we ran:
- None of them falls back per character to another font.
Zürichsurvived, while東京and🚀turned into blank boxes or disappeared completely across PDFKit, jsPDF, pdfmake and React-PDF. If your users can type CJK, emoji or mixed scripts, font fallback becomes your problem to build and bundle. - Accessibility tagging is missing or half-manual. Four of the five outputs had no structure tree and no image alt text at all. Even the one library with a tagging API (PDFKit) still failed PDF/UA-1.
Library-by-library notes
PDFKit 0.21.0 (pdfkit-default, pdfkit-pdfua)
PDFKit produced the smallest files in the entire 26-sample benchmark (31 KB default, 34 KB with PDF/UA tagging), and it is the only JS library here with a real tagging API (tagged: true, subset: 'PDF/UA', doc.struct() and markContent()).
The catch is that you build the structure tree by hand, and the higher-level helpers do not wire it up for you. In pdfkit-pdfua.pdf, the headings, paragraphs, Figure /Alt and outer L/Table wrappers were tagged, but the list items (LI) and table rows/cells (TR/TD) were not, links were left untagged (7.18.5-1, 7.18.5-2), and the missing CJK/emoji glyphs left .notdef and invalid ToUnicode references (7.21.8-1, 7.21.7-2). It still failed PDF/UA-1 on 6 rules (11 checks) and PDF/A-2a on 8 rules (1,232 checks).
jsPDF 4.2.1 + jspdf-autotable (jspdf)
jsPDF produced the largest file in the entire 26-sample set: 782 KB for a two-page report (roughly 25x PDFKit and 12x makesPDF). That happens because jsPDF embeds whole TTF font files without subsetting, while also referencing 14 unembedded standard fonts in the catalog.
Beyond size, jsPDF is untagged (9 rules / 331 UA-1 checks, 6 rules / 965 A-2a checks), has no alt-text API, and requires manual text-run splitting if you want inline bold or italic inside a paragraph.
pdfmake 0.3.15 (pdfmake)
pdfmake wraps PDFKit in a declarative JS object model (content: [...], tables, styles), which is much nicer to maintain than manual x/y drawing. Our sample came out compact (34 KB, 2 pages), but completely untagged (11 rules / 1,046 UA-1 checks, 6 rules / 2,424 A-2a checks) with no alt text and no CJK/emoji fallback. In browser apps, pdfmake's virtual-filesystem font bundle also adds roughly 1 MB to your client payload. See pdfmake vs makesPDF for the side-by-side.
@react-pdf/renderer 4.9.2 (react-pdf)
React-PDF lets you write layouts as JSX (<Document><Page><View><Text>) backed by Yoga flexbox and PDFKit. Output was compact (33 KB, 2 pages), and its language prop sets /Lang, but there is no structure tree and no alt text (11 rules / 243 UA-1 checks, plus unembedded Helvetica and .notdef references from dropped glyphs).
If you already have React-PDF templates and need tagged PDF/UA-1 + PDF/A-2a output, our React-PDF migration converter can turn existing JSX templates into makesPDF DSL, and react-pdf vs makesPDF covers the trade-offs in detail.
What about pdf-lib?
We didn't include pdf-lib in the table because it is a low-level PDF manipulation library (merging, splitting, stamping, filling AcroForms), not a document layout engine. It has no word wrapping, table layout or pagination. Great when you need to modify an existing PDF in JS; wrong tool for authoring reports from scratch.
Pros and cons
Pros
- Runs directly in Node.js or the user's browser with zero external services or network calls.
- Works offline and keeps sensitive document data on the client if you generate in-browser.
- Fine for simple, English-only receipts or labels where accessibility and archiving aren't required.
Cons
- No out-of-the-box PDF/UA-1 or PDF/A-2a compliance; PDFKit's tagging API still takes manual plumbing and misses lists, tables and links.
- No per-character font fallback for CJK or colour emoji.
- Manual pagination and layout work (except pdfmake and React-PDF), and large client bundle sizes when bundling fonts in the browser.
When a JS library is the right call
- You must generate PDFs client-side in the browser with no server round-trip (offline apps or strict zero-egress privacy requirements).
- You need a simple, fixed-layout receipt or ticket in Latin script and have no PDF/UA or PDF/A obligations.
If you need server-side PDFs with working CJK/emoji and real PDF/UA-1 or PDF/A-2a compliance, look at Typst, CSS paged media or makesPDF.