News for hackers. Stuff that matters.
Re:Borb – A Python library to read, write, and edit PDF files by alephu5 on Saturday September 18, 2021 @06:14AM (#28575016)
Amazing, I've been yearning for something like this for years but have always been told it's impossible. Can't wait to try it
Re:Borb – A Python library to read, write, and edit PDF files by eurasiantiger on Saturday September 18, 2021 @08:03AM (#28575537)
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.
Re:Borb – A Python library to read, write, and edit PDF files by anonymouse008 on Saturday September 18, 2021 @09:23AM (#28576067)
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.

Re:Borb – A Python library to read, write, and edit PDF files by dunham on Saturday September 18, 2021 @11:29AM (#28576989)
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 by mkl on Saturday September 18, 2021 @11:43AM (#28577082)
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 by mcswell on Saturday September 18, 2021 @12:17PM (#28577299)
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 by dunham on Saturday September 18, 2021 @03:52PM (#28578759)
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.