3 ms·
It's certainly true that there are a lot of PDF renderers out there with subtle incompatibilities (and bugs), and also a lot of PDF files with subtle nonconform
by kragen 5y ago
It's certainly true that there are a lot of PDF renderers out there with subtle incompatibilities (and bugs), and also a lot of PDF files with subtle nonconformances. However, that doesn't seem like a good reason to not write a new PDF generator!
Instead, write a conformant one. Better, write one that not only conforms, but also isn't affected by any of the bugs in popular PDF renderers, by testing against all of them. Shawn Davis at LevelUp Research, working on the same DARPA project I'm currently on, has written the amazing SPARCLUR https://youtu.be/6I6E1N3CJzQ https://youtu.be/6I6E1N3CJzQ (no sound) https://github.com/levelupresearch/sparclur https://github.com/levelupresearch/sparclur https://pypi.org/project/sparclur/ https://pypi.org/project/sparclur/ which will feed your test PDF to Ghostscript, MuPDF, PDFium, PDFMiner, Poppler, QPDF, Xpdf, and some other PDF engines, and compare the results. That way you can see not only if any of them produce errors and warnings, but also if they render it differently or extract different text from it. SPARCLUR is Apache-licensed, written in Python, and very well integrated with Jupyter.
(We've developed some other tools for this as well, but they're not as accessible.)
SPARCLUR doesn't test your PDF against Adobe's implementation, or for that matter Foxit, and I don't remember why.
But basically if you're going to generate PDF files you might as well feed them to SPARCLUR's Spotlight and automatically verify that they work identically, or near enough, in half a dozen independently implemented PDF renderers. Hopefully SPARCLUR will dramatically improve the software quality and compatibility of future PDF generators.
- zinekeller 5y ago> against Adobe's implementation Hard to automate, Windows, macOS and Linux versions have differences > Foxit No Linux version, even harder automation than Adobe's
- kragen 5y agoYeah, that would explain it.
- layer8 5y agoThat’s just a sanity check though, not an actual conformance test.
- kragen 5y agoWhile I agree that it's not an actual conformance test, in the sense that it won't detect deviations from the spec that all of the parsers forgive (for example, using a space instead of a line ending between "startxref" and the offset of the xrefs), it is in many cases more rigorous than an actual conformance test, because there are dark corners of the PDF spec that no PDF renderer implements correctly.
- gettalong 5y agoThanks for mentioning SPARCLUR - I didn't know that one and will certainly have a look at it.
- kragen 5y agoIt's brand new!