Live data from Hacker News

Borb – A Python library to read, write, and edit PDF files

borbpdf.com

21–30 of 50 posts

Re: Borb – A Python library to read, write, and edit PDF files

#21
post #11

Earlier quoted context omitted.

> There are many evolutionary layers and no formal specification or verification; There is a specification, but it's very complicated.

PDF uses postscript, which is Turing equivalent. It's a document format with the halting problem.

Postscript files are often rendered into PDF, but PDF doesn't use postscript.

Re: Borb – A Python library to read, write, and edit PDF files

#22

The README in the GitHub repo for borb is a bit of a better explainer than this landing page (especially for Python programmers). https://github.com/jorisschellekens/borb/blob/master/README....

And the example repository shows off its capabilities better too:

https://github.com/jorisschellekens/borb-examples

Re: Borb – A Python library to read, write, and edit PDF files

#23
post #22

The README in the GitHub repo for borb is a bit of a better explainer than this landing page (especially for Python programmers). https://github.com/jorisschellekens/borb/blob/master/README....

And the example repository shows off its capabilities better too: https://github.com/jorisschellekens/borb-examples

The examples are pretty useful, seeing as there apparently isn't any documentation yet.

It a really amazing project. One of those that makes you go: "Wait we didn't have this before?"

Re: Borb – A Python library to read, write, and edit PDF files

#24
post #11

Earlier quoted context omitted.

> There are many evolutionary layers and no formal specification or verification; There is a specification, but it's very complicated.

PDF uses postscript, which is Turing equivalent. It's a document format with the halting problem.

It's based on postscript, like json is based on javascript. I don't believe there are any control flow (or even general arithmetic?) instructions in the content streams, so I don't see how it could be Turing complete. It's just a sequence of drawing and transformation commands, like SVG.

I presume the extensions to embed javascript are Turing complete, and IMO do not belong in a PDF file.

I've also heard that some of the embedded font formats have features that are Turing complete, but I don't know the details on that.

If there is a way to implement a Turing machine in PDF, outside of the fonts and javascript, I'd love to see the details. (I know somebody managed it with just the macro expansion bit of TeX.)

Re: Borb – A Python library to read, write, and edit PDF files

#25
post #11

Earlier quoted context omitted.

> There are many evolutionary layers and no formal specification or verification; There is a specification, but it's very complicated.

PDF uses postscript, which is Turing equivalent. It's a document format with the halting problem.

PDF does not use Postscript, and is not Turing complete. Its drawing model is based on Postscript's (with additions), but its instruction set is focused on drawing, and can't do programming. Here is the instruction set, with equivalent Postscript commands where applicable: https://www.adobe.com/content/dam/acom/en/devnet/pdf/pdfs/PD.... Most parts of the Postscript language have no PDF equivalent.

Other things like JavaScript and Flash can be embedded, but they are extras on top of the document.

Re: Borb – A Python library to read, write, and edit PDF files

#26

Earlier quoted context omitted.

It is literally impossible for all PDFs, since some of them may not have any kind of semantic structure and consist of a set of graph bitmaps laid out at specific coordinates to make up blocks of text.

The best PDF bug is when the linker between the Adobe character value and the font/language is broken and you get random Unicode like values with no way to connect the two. Infuriating.

Some PDF files intentionally include a bad character mapping table (and reorder the font) as a form of DRM.

Re: Borb – A Python library to read, write, and edit PDF files

#27
Haven't tested this lib, however be careful before including it in your project because of its license (it is dual licensed agpl/commercial). This means that you can use it only if your project is GPL or else you need a commercial license.

On the other hand, the reportlab pdf generation library (which is what I actually use) offers a permissive language in its open source version (and a commercial reportlab plus version), so it can be included in all kinds of projects.

Re: Borb – A Python library to read, write, and edit PDF files

#29
post #26

Earlier quoted context omitted.

The best PDF bug is when the linker between the Adobe character value and the font/language is broken and you get random Unicode like values with no way to connect the two. Infuriating.

Some PDF files intentionally include a bad character mapping table (and reorder the font) as a form of DRM.

It's not very effective against anyone determined though. You can OCR easily. You can also rebuild the character mapping from the shapes of the glyphs, and in most languages there are few enough that you can even do it by hand.

Re: Borb – A Python library to read, write, and edit PDF files

#30

Haven't tested this lib, however be careful before including it in your project because of its license (it is dual licensed agpl/commercial). This means that you can use it only if your project is GPL or else you need a commercial license. On the other hand, the reportlab pdf generation library (which is what I actually use) offers a permissive language in its open source version (and a commercial reportlab plus vers…

Confusingly, while the README says AGPL/commercial, the LICENSE file (https://github.com/jorisschellekens/borb/blob/master/LICENSE) says it's GPL.
Post reply on HN