Skip to content

Performance

All benchmarks run via phpbench on the same machine. phpdftk generates spec-compliant PDFs with proper xref tables, binary comments, and typed trailers.

Library1 page5 pages10 pages50 pages100 pages
phpdftk938 us1.1 ms1.2 ms2.2 ms3.5 ms
FPDF432 us459 us541 us833 us1.2 ms
TCPDF5.4 ms5.7 ms6.3 ms10.7 ms16.2 ms
mPDF12.4 ms14.7 ms16.4 ms33.0 ms54.4 ms
Dompdf5.4 ms7.7 ms10.4 ms39.5 ms88.0 ms

phpdftk is 3-25x faster than TCPDF, mPDF, and Dompdf. It’s within 2x of FPDF (a minimal library with no font embedding, no encryption, no annotations).

Library1 page10 pages100 pages
phpdftk5.8 MB5.9 MB7.4 MB
FPDF5.3 MB5.3 MB5.3 MB
TCPDF13.0 MB13.0 MB13.0 MB
mPDF17.8 MB17.9 MB18.6 MB
Dompdf9.5 MB10.0 MB16.1 MB
Library1 page10 pages100 pages
phpdftk601 us867 us3.8 ms
smalot/pdfparser871 us1.1 ms2.9 ms
setasign/fpdi953 us1.5 ms21.5 ms
  • Generation: create N pages with text content, serialize to PDF bytes
  • Memory: peak memory_get_peak_usage(true) during generation
  • Parsing: open PDF, extract catalog/info/version, iterate all pages

Cost of running ISO standard validation during PDF generation (10 pages with embedded TrueType font):

ProfileTime
PDF/A-1b27.6 ms
PDF/UA-125.4 ms
PDF/X-426.5 ms
PDF/VT-129.4 ms
PDF/X-5g29.1 ms
ZUGFeRD BASIC30.8 ms
PDF/mail-134.0 ms
PDF/R-14.0 ms

Most of the cost is font embedding and OutputIntent setup, not the constraint checking itself.

phpdftk handles both classic xref tables (20-byte entries per ISO 32000-2 SS7.5.4) and cross-reference streams (PDF 1.5+). Many competitors fail on one or both formats.

Terminal window
# Full benchmark suite (generates docs/generated/benchmarks.md)
mise run benchmark
# Single benchmark class
vendor/phpbench/phpbench/phpbench run benchmarks/GeneratePdfBench.php --report=default