Live data from Hacker News

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

borbpdf.com

31–40 of 50 posts

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

#31
post #6

I am a math professor with a scanned exam grading workflow that I hacked together as Bash scripts using various open source command line tools. I feed all the exams through a sheet-fed scanner, decode bar codes to identify problems and students, add radio buttons for entering and tracking scores (0-6 per problem), and create PDF "books" per problem for grading and annotating. Having grad students help grade paper is…

Perhaps you might be interested in the Zesje project: https://gitlab.kwant-project.org/zesje/zesje

More information: https://sandbox.grading.quantumtinkerer.tudelft.nl/, https://zesje.tudelft.nl/about/

It sounds like it's still mostly a prototype?

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

#32

So how does this compare to the python bindings of mupdf? Which IMO is the most featureful module to manipulate PDFs in python (I'm a bit buffled by all the comments that something like this didn't exist before).

Borb is pure python. MuPDF is C with bindings. Reportlab is pure python.

I use reportlab combined with PyPDF2 and pdf-redactor. It would be nice to see a comparison with the existing tools.

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

#33
post #29
post #26

Earlier quoted context omitted.

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.

You can OCR if you're using a Latin script with few if any accent marks. Depending on your OCR engine, I suppose you could do Cyrillic too. Other scripts, not so much. (And yes, I'm a computational linguist, so we deal with non-Roman scripts all the time, particularly Arabic script. But I suppose that's not a problem for most people here :-).)

There might be some Latin script fonts that cause problems, but I haven't looked into that very much--I do recall we had problems with an italic font.

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

#34
post #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.

I'd guess it's just a copy-pasta error, because all the source files contain the AGPL header text: https://github.com/jorisschellekens/borb/blob/v2.0.9.1/borb/... and https://github.com/jorisschellekens/borb/blob/v2.0.9.1/borb/... for example

But the plot thickens! It seems the top-level LICENSE file was actually changed 13 days ago _away_ from AGPL https://github.com/jorisschellekens/borb/blame/master/LICENS...

So, yeah, confusingly for sure

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

#35
post #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.

An AMBIGUOUS LICENSE situation is a red flag.

Was the issue raised with the author?

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

#36
post #6

I am a math professor with a scanned exam grading workflow that I hacked together as Bash scripts using various open source command line tools. I feed all the exams through a sheet-fed scanner, decode bar codes to identify problems and students, add radio buttons for entering and tracking scores (0-6 per problem), and create PDF "books" per problem for grading and annotating. Having grad students help grade paper is…

You should consider looking into Gradescope (Gradescope.com). As a former TA, I can attest to it making grading much more pleasant and streamlined than it would be otherwise.

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

#37
post #6

I am a math professor with a scanned exam grading workflow that I hacked together as Bash scripts using various open source command line tools. I feed all the exams through a sheet-fed scanner, decode bar codes to identify problems and students, add radio buttons for entering and tracking scores (0-6 per problem), and create PDF "books" per problem for grading and annotating. Having grad students help grade paper is…

Would be cool to know the differences to Ruby's HexaPDF. One is certainly the license.

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

#38
post #24

Earlier quoted context omitted.

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…

[deleted]

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

#39

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…

ReportLab is indeed a great library. Another great one is WeasyPrint. How are these compared with Borb?

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

#40
post #29
post #26

Earlier quoted context omitted.

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.

When I came across this I already had a pristine copy of the font, so I just compared the program for each character to determine the mapping. (I was automating the decoding.) I agree that there is little to no security there.

But the point that I was not so clearly trying to make was that sometimes the messed up encoding is intentional and not a bug.

Post reply on HN