Live data from Hacker News

So you want to modify the text of a PDF by hand (2020)

gist.github.com

91–100 of 103 posts

Re: So you want to modify the text of a PDF by hand (2020)

#91

Is there any tool that competes with Adobe Acrobat? Like the censoring tool is rarely founs anywhere else.

PDF-XChange Editor. Not really used it much (have Acrobat for work and have checked that some things work as far as viewing).

Re: So you want to modify the text of a PDF by hand (2020)

#92
post #65
post #63

Earlier quoted context omitted.

That's awesome. I'm relying a lot on Amazon Textract for my PDF parsing needs. Do you have any other insights on how to do a good job at that natively, i.e. without a cloud provider? Especially when dealing with tables.

PDF format does not give you enough semantic information to understand there is a table. The stream contains instructions such as moving to a coordinate, adding some text, adding some lines. No tool can extract tables with 100% precision.

Yeah, but Textract uses OCR/computer vision even in PDFs with embedded text data and it can extract tables incredibly well. I believe there isn't an open source equivalent. Maybe some advanced usage of tesseract?

Re: So you want to modify the text of a PDF by hand (2020)

#93

Is there any tool that competes with Adobe Acrobat? Like the censoring tool is rarely founs anywhere else.

PDF-XChange Editor. Not really used it much (have Acrobat for work and have checked that some things work as far as viewing).

Thank you, it was a bit unclear if I had to pay in order to redact content but I guess I'll have to download it and give it a shot in order to find out.

Re: So you want to modify the text of a PDF by hand (2020)

#94

You can do this: pdf2ps a.pdf # convert to postscript "a.ps" vim a.ps # edit postscript by hand ps2pdf a.ps # convert back to pdf Some complex pdf (with embedded javascript, animations, etc) fail to work correctly after this back and forth. Yet for "plain" documents this works alright. You can easily remove watermarks, change some words and numbers, etc. Spacing is harder to modify. Of course you need to know some po…

If you can put javascript and animations in pdf, what's stopping you from making a frontend in it? I wonder what are the frontiers of things you can do in pdf. Honestly, it seems like only malware authors benefit from the complexity of pdfs.

You might enjoy this about controlling a river using Tex and postscript

http://sdh33b.blogspot.com/2008/07/icfp-contest-2008.html?m=...

Re: So you want to modify the text of a PDF by hand (2020)

#95
post #92
post #65

Earlier quoted context omitted.

PDF format does not give you enough semantic information to understand there is a table. The stream contains instructions such as moving to a coordinate, adding some text, adding some lines. No tool can extract tables with 100% precision.

Yeah, but Textract uses OCR/computer vision even in PDFs with embedded text data and it can extract tables incredibly well. I believe there isn't an open source equivalent. Maybe some advanced usage of tesseract?

This seems to have stalled but if popped up a few times on HN in the past. Might still be worth a look.

https://github.com/tabulapdf/tabula

Are the documents scans, or do they have real text on them? It’s worth trying to convert them to svg or html using “mutool convert” and then seeing what you can do with the results. If you’re dealing with the same type of document each time you’ll probably find the patterns in there are common enough that you can easily grab what you want.

Re: So you want to modify the text of a PDF by hand (2020)

#96
post #89
post #78

Earlier quoted context omitted.

> I’m a sadist, I read it for fun. I think this is called masochist. Now, if you participated in writing the spec or were making others read it...

Yup, slip of the tongue. Though, I do make other people read the spec at work, so I’m that too.

a sadist is a masochist who follows the golden rule

Re: So you want to modify the text of a PDF by hand (2020)

#97

The PDF specification is wild. My current favourite trivia is that it supports all of Photoshop's layer blend modes for rendering overlapping elements.[1] My second-favourite is that it supports appended content that modifies earlier content, so one should always look for forensic evidence in all distinct versions represented in a given file.[2] It's also a fun example of the futility of DRM. The spec includes passwo…

The permission field can also lead you down the rabbit hole of discovering noncompliance to its specification in some PDF writers and workarounds for these that may or may not be present in different PDF readers/libraries.

Re: So you want to modify the text of a PDF by hand (2020)

#98
post #77

What people often miss about PDF is that it's closer to an image format in some ways than to a Word document. Word documents, PDFs and images are in document editing what DAW projects, midis and mp3 files are in music and what Java source code, JVM bytecode and pure x86 machine code are in software. The primary purpose of a PDF file is to tell you what to display (or print), with perfect clarity, in much fewer bytes…

The original goal of PDF was to have a portable print fidelity copy; WYSIWYG for real. You could take a PDF file and print it on a laser printer, a linotype, or a screen and it would look the same. If you printed it on a postscript printer it would look exactly the same (or better, if you used type 1 fonts).

PDF is pretty much a symbolic representation of what needs to be printed out. It's symbolic so it can get rasterized onto whatever device in question, in a way that should be as accurate as possible to a print version.

That's the primary requirement of PDF, and has been since the beginning.

They added a bunch of interactive stuff to it, which are used occasionally (forms). But to understand PDF you need to understand the above first.

Re: So you want to modify the text of a PDF by hand (2020)

#99

The PDF specification is wild. My current favourite trivia is that it supports all of Photoshop's layer blend modes for rendering overlapping elements.[1] My second-favourite is that it supports appended content that modifies earlier content, so one should always look for forensic evidence in all distinct versions represented in a given file.[2] It's also a fun example of the futility of DRM. The spec includes passwo…

I used to be rich with selling a part of the stuff. FrameMaker. Used to be $5K US / copy Which came originally from Frame Technologies. [ Hi Steve Kirsch . I see you're rich still ]. PDF specification is wild. So right you are. At the time, many - including yours truly - said it was rude capitalism. So, you got it. People did not talk enough about DRM. Ps: I left Adobe embrace courtesy of my then wife, and me myself. I hate DRM as a user and as a -former- Salesman. Hola

Re: So you want to modify the text of a PDF by hand (2020)

#100

Earlier quoted context omitted.

That also breaks search (and more importantly screen reader accessibility), and if you're professionally required to specifically produce PDFs with these security features enabled, you're pretty likely to be working in a context where that would be illegal.

It is impossible to stop text copying without breaking screen reading, because the screen reader could just log everything it reads.

You could do it (and Adobe has with some documents AFAIK) by using some kind of DRM solution, limiting access to approved software. That software wouldn't then be allowed to expose its UI tree to accessibility APIs, except for approved screen readers that embed a particular key in their executables. Those approved screen readers would have restrictions around what they can do with the text. Sure, everything can be broken, for example with third-party fake speech synthesizers or speech recognition applied to the screen reader's output (as contemporary OSes don't even provide good DRM mechanisms for audio), but it would make the process that much harder.
Post reply on HN