Earlier quoted context omitted.
You can embed flash in PDF?!?
In the good old days you could embed executable code in a PDF. Interactive flash games. Java applets. Sanity has prevailed and a lot of that just doesn’t work anymore, but IIRC Adobe wanted PDF to be “the” file interchange format.
Ask HN: Why is the PDF format so inaccessible?
61–70 of 109 posts
Re: Ask HN: Why is the PDF format so inaccessible?
#62Most of the best, most comprehensive PDF libraries are written for Java. There are libraries for other languages but they tend to be incomplete or flawed. There’s also some great paid libraries for C#, but if you want free, I’d recommend looking into Apache PDFBox.
Re: Ask HN: Why is the PDF format so inaccessible?
#63Re: Ask HN: Why is the PDF format so inaccessible?
#64As for libraries, it seems PDFKit is the dominant one. https://github.com/foliojs/pdfkit As to why it’s so inaccessible…because Adobe created this monstrosity to do just about everything. Text, fonts, vector graphics, raster graphics, forms, color spaces, JavaScript, encryption, signatures, 3D artwork, video, audio, Flash, and probably more. It’s bonkers as to what it can possibly include, and it was developed during…
You can embed flash in PDF?!?
(A lot of those “interactive” features are exposed in Adobe InDesign, hence my passing, regrettable familiarity.)
Re: Ask HN: Why is the PDF format so inaccessible?
#65I redid it with the FPDF library for php, and it worked out fine. I tried some new features of tcpdf, and it wasn't much work to convert.
Using inkscape to make an EPS out of an svg was also challenging.
I know that postscript and PDF is based on a forth stack machine, if I really had to get that low.
Re: Ask HN: Why is the PDF format so inaccessible?
#66Re: Ask HN: Why is the PDF format so inaccessible?
#67Re: Ask HN: Why is the PDF format so inaccessible?
#68The PDF spec is officially available here: http://www.adobe.com/go/pdfreference There’s also this book which provides a good introduction and overview and is useful for understanding how the format works (although the PDF reference itself is pretty decent too, as far as specs go): https://www.oreilly.com/library/view/developing-with-pdf/978... (You can find a PDF copy if you look around.) EDIT: There’s also https://w…
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 (no sound) https://github.com/levelupresearch/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.
Re: Ask HN: Why is the PDF format so inaccessible?
#69Cause it belongs to Adobe and they clearly don’t want to make it easy for developers to work with it.
The PDF specification, hosted by Adobe, free for you to download… (pay attention, this is a big PDF) https://opensource.adobe.com/dc-acrobat-sdk-docs/standards/p... Adobe specifically negotiated to make this freely available. From the document: This document you are now reading is a copy of the ISO 32000-1 standard. By agreement with ISO, Adobe Systems is allowed to offer this version of the ISO standard as a free PD…
The spec is 756 pages. For the 2008 spec. How is that very straightforward? My god.
Even the 2003 version clocks in at 696 pages and apparently includes "Interactive Forms", "Movies" and "Sounds".
Here's the link https://web.archive.org/web/20101214132912/http://partners.a...
How is that _straightforward_?
Re: Ask HN: Why is the PDF format so inaccessible?
#70The PDF spec is officially available here: http://www.adobe.com/go/pdfreference There’s also this book which provides a good introduction and overview and is useful for understanding how the format works (although the PDF reference itself is pretty decent too, as far as specs go): https://www.oreilly.com/library/view/developing-with-pdf/978... (You can find a PDF copy if you look around.) EDIT: There’s also https://w…
My top tip for understanding PDFs is to take one that you have a decompress it then open with a text editor.
mutool clean -d in.pdf out.pdf
What you'll find is very approachable for a developer. It's a tree of nodes of different types. Some are dictionaries, some are streams of other data. All of them are documented in the spec. There's all sorts of wonderful corners, like spot printing colors.PDFs are actually ok, wait till you dig into the fonts. Now there's the real dark art of the ancients.