1RPS.club

PDF Generators Comparison and Benchmark: PDFKit, PDFMake, React-PDF, Puppeteer & wkhtmltopdf

When you need to generate PDFs programmatically, the choice of library can dramatically impact your application's performance and server costs. With multiple solutions available — from lightweight libraries like PDFKit to browser-based approaches like Puppeteer — the performance difference between them can be overwhelming.

To find out which PDF generator is better, I benchmarked 5 popular solutions across different document sizes and scenarios. The results reveal performance gaps of up to 130x between the fastest and slowest options, with file sizes varying by up to 18x.

TL;DR: Recommendations

Solutions Under Test

JavaScript PDF Libraries:

Browser-Based Solutions:

Font Impact: Base 14 vs Custom Fonts

A crucial factor in PDF generation performance is font handling. The PDF standard defines Base 14 fonts (also known as Standard 14 fonts) — a set of fonts that must be available in every PDF viewer without embedding. These include Helvetica, Times-Roman, Courier, and Symbol fonts. When using Base 14 fonts, libraries can avoid font embedding entirely, resulting in smaller files and faster generation.

⚠️ Unicode/Internationalization Caveat: Standard fonts have limited character set support. While excellent for English and basic Latin scripts, they may not support Cyrillic, Chinese, Arabic, or many special characters.

Each library was tested with both scenarios:

Document Complexity

Documents were generated with text content and tables across three complexity levels: small (10 elements), medium (100 elements), and large (1000 elements).

Benchmark Environment

Hardware:

Software:

Test Methodology:

Benchmark code

Server Performance: Requests Per Second

The server performance test measures how many PDF generation requests each library can handle per second.

Text Documents Performance

Small documents (10 paragraphs) (RPS)

PDFKit
13.07
PDFKit (Helvetica)
64.02
PDFMake
9.31
PDFMake (Helvetica)
26.96
React-PDF
8.51
React-PDF (Helvetica)
16.83
Puppeteer
0.5
wkhtmltopdf
3.42

Medium documents (100 paragraphs) (RPS)

PDFKit
8.69
PDFKit (Helvetica)
14.66
PDFMake
3.84
PDFMake (Helvetica)
4.03
React-PDF
1.15
React-PDF (Helvetica)
1.3
Puppeteer
0.51
wkhtmltopdf
2.92

Large documents (1000 paragraphs) (RPS)

PDFKit
2.21
PDFKit (Helvetica)
1.77
PDFMake
0.6
PDFMake (Helvetica)
0.45
React-PDF
0.07
React-PDF (Helvetica)
0.08
Puppeteer
0.35
wkhtmltopdf
1

Table Generation Performance

Tables are particularly challenging for PDF generators, especially when they contain many rows.

Small tables (10 rows) (RPS)

PDFKit
2.8
PDFKit (Helvetica)
58.74
PDFMake
11.96
PDFMake (Helvetica)
54.74
React-PDF
5.22
React-PDF (Helvetica)
5.85
Puppeteer
0.55
wkhtmltopdf
3.48

Medium tables (100 rows) (RPS)

PDFKit
0.45
PDFKit (Helvetica)
15.5
PDFMake
7.28
PDFMake (Helvetica)
15.46
React-PDF
0.71
React-PDF (Helvetica)
0.7
Puppeteer
0.5
wkhtmltopdf
2.99

Large tables (1000 rows) (RPS)

PDFKit
0.03
PDFKit (Helvetica)
1.8
PDFMake
1.49
PDFMake (Helvetica)
1.71
React-PDF
0.03
React-PDF (Helvetica)
0.03
Puppeteer
0.25
wkhtmltopdf
1

Performance Analysis

File Size Comparison

Generated file sizes vary significantly between libraries and font choices, directly impacting bandwidth costs and download times.

Text Document File Sizes

Small documents (KB)

PDFKit
15.2
PDFKit (Helvetica)
2
PDFMake
19.8
PDFMake (Helvetica)
4.6
React-PDF
17.8
React-PDF (Helvetica)
3.3
Puppeteer
14.7
wkhtmltopdf
9.9

Large documents (KB)

PDFKit
113.9
PDFKit (Helvetica)
100.2
PDFMake
368.5
PDFMake (Helvetica)
314.3
React-PDF
144.2
React-PDF (Helvetica)
117.5
Puppeteer
352.5
wkhtmltopdf
206.6

Table File Sizes

Small tables (KB)

PDFKit
18
PDFKit (Helvetica)
2.7
PDFMake
19.9
PDFMake (Helvetica)
2.8
React-PDF
21.7
React-PDF (Helvetica)
3.7
Puppeteer
33
wkhtmltopdf
12

Large tables (KB)

PDFKit
119.5
PDFKit (Helvetica)
100.2
PDFMake
127
PDFMake (Helvetica)
96.6
React-PDF
201.2
React-PDF (Helvetica)
150.9
Puppeteer
1,714.6
wkhtmltopdf
144.2

File Size Analysis

Using standard fonts (Helvetica) consistently produces smaller files. This is especially important for small documents. PDFKit generates 2KB files with Helvetica vs 15.2KB with Roboto for small documents — a 7.6x difference. This occurs because standard fonts don't require embedding, while custom fonts like Roboto must include the full font data in the PDF.

Puppeteer produces larger files, especially for complex tables (1.7MB vs ~100-200KB for other libraries).

Conclusion

PDFKit

Pros:

Cons:

PDFKit is ideal when you need maximum server performance and don't mind the setup complexity.


PDFMake

Pros:

Cons:

PDFMake is perfect for efficiently generating relatively simple documents.


React-PDF

Pros:

Cons:

React-PDF can currently only be used for generating simple and small text documents. No advantages over PDFMake were found.


Puppeteer

Pros:

Cons:

Puppeteer is suitable when you want convenient document generation for small volumes or have access to unlimited server resources.


wkhtmltopdf

Pros:

Cons:

wkhtmltopdf works more efficiently than Puppeteer but requires developers to work with legacy CSS standards.