Live data from Hacker News

Ask HN: Why is the PDF format so inaccessible?

news.ycombinator.com

61–70 of 109 posts

Re: Ask HN: Why is the PDF format so inaccessible?

#61
post #55

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.

And those weren’t even things when the PDF was first created.

Re: Ask HN: Why is the PDF format so inaccessible?

#62
post #37

Most 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.

I recently had this revelation. I remember how easy it was doing this in java a decade ago...and how underwhelmed I was finding a library to achieve the same in Python. There seems to be no clear winning library in Python and some havent been maintained for years on.

Re: Ask HN: Why is the PDF format so inaccessible?

#64
post #33

As 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?!?

Yeah, I had forgotten that when I was looking through the version history. I remembered most of those features, but when I saw Flash, I had to sit and slowly blink for a minute.

(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?

#65
I had to recreate some PDFs at work that were created by "iText by Lowagie" which must have been a java library at the time.

I 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.

http://fpdf.org/

https://tcpdf.org/

https://wiki.c2.com/?ForthPostscriptRelationship

Re: Ask HN: Why is the PDF format so inaccessible?

#67
I think it's the same as ms-office, they make a format, and they are the only ones that make the software to use the files in that format, it's funny, because adobe reader is very bad, and they ended up "giving it up", now ISO handles the spec, as for generating PDFs, maybe check libreoffice? or some other software that creates PDFs with the source available

Re: Ask HN: Why is the PDF format so inaccessible?

#68
post #32

The 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…

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 (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?

#69
post #24
post #8

Cause 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…

> Very straightforward format.

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?

#70
post #32

The 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…

The spec is pretty amazing and very readable, for anyone wondering if they should look into it.

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.

Post reply on HN