Menu

5 Python PDF libraries vs 1,068 broken PDFs: what crashed, and why one of my explanations was wrong
📰

5 Python PDF libraries vs 1,068 broken PDFs: what crashed, and why one of my explanations was wrong

DEV Community: python·Prometheus·9 days ago
#p3CmVuYM
#devtopython#devto#dev#file#pdfplumber
Reading 0:00
15s threshold

I fed 1,068 broken PDFs to five Python libraries and asked each one for the text. The files are Mozilla's pdf.js test suite: PDFs people attached to bug reports over the years, with broken cross-reference tables, strange fonts and fuzzed bytes. If your code reads PDFs that strangers upload, these are the files that will eventually reach it.

Library Failed* Failed where 3+ others worked Total time Slowest file

PyMuPDF 2.1 5 2 14 s 5.9 s

pypdfium2 5.14.0 14 2 6 s 0.6 s

pypdf 6.21.4 23 7 83 s 13.8 s

pdfminer.six 20260107 22 6 204 s timeout (60 s)

pdfplumber 0.11.10 23 7 225 s timeout (60 s)

* Raised an error or hit the 60-second limit. Not counted: 12 password-protected files that at least two libraries reported as needing a password. Python 3.13, 2-vCPU ARM server, each library in its own worker processes.

The fast two are 6 to 40 times faster

pypdfium2 got through all 1,068 files in 6 seconds. PyMuPDF needed 14.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.