This topic comes up periodically as most people think PDFs are some impenetrable binary format, but they’re really not. They are a graph of objects of different types. The types themselves are well described in the official spec (I’m a sadist, I read it for fun). My advice is always to convert the pdf to a version without compressed data like the author here has. My tool of choice is mutool (mutool clean -d in.pdf ou…
So you want to modify the text of a PDF by hand (2020)
61–70 of 103 posts
Re: So you want to modify the text of a PDF by hand (2020)
#62Earlier quoted context omitted.
> It is a shame Adobe designed a format so hard to work with PDF was not designed to be editable, nor for anyone to "work with" it in that way. It was designed (at least the original purpose circa 1989) to represent printed pages electronically in a format that would view and print identically everywhere. In fact, the initial advertising for the "value" of the PDF format was exactly this, no matter where a recipient…
Wasn't the PDF format based on the Illustrator format? The weird thing to me is people using a distribution format as an original source. It's right up there with video cameras shooting an acquisition source as an MP4 and all of the negative baggage that comes with that.
Re: So you want to modify the text of a PDF by hand (2020)
#63This topic comes up periodically as most people think PDFs are some impenetrable binary format, but they’re really not. They are a graph of objects of different types. The types themselves are well described in the official spec (I’m a sadist, I read it for fun). My advice is always to convert the pdf to a version without compressed data like the author here has. My tool of choice is mutool (mutool clean -d in.pdf ou…
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.
Re: So you want to modify the text of a PDF by hand (2020)
#64You 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…
Even if the output was correct, we still needed to re-order pages, apply barcodes for mail machine processing and postal sorting, and produce reports - which usually involved text scraping off the page to get an address via perl and other tools. Much easier in PS than PDF usually, but sometimes very unreliable when e.g. their PDFs were 'secure' and didn't have correct glyph mappings.
In the worst cases, they would supply single document PDFs, and merging those would cause an explosion of subset fonts in the output which would fill the printer's memory and crash it. When I stopped working in the area, I think there still wasn't a useful tool to consolidate and merge subset fonts known to come from the same parent font - it would have been a very useful tool and should be possible but I didn't have the time or knowledge to look into it.
Re: So you want to modify the text of a PDF by hand (2020)
#65This topic comes up periodically as most people think PDFs are some impenetrable binary format, but they’re really not. They are a graph of objects of different types. The types themselves are well described in the official spec (I’m a sadist, I read it for fun). My advice is always to convert the pdf to a version without compressed data like the author here has. My tool of choice is mutool (mutool clean -d in.pdf ou…
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.
Re: So you want to modify the text of a PDF by hand (2020)
#66PDF is such a weird format. Not so long ago I had to write some Java code for manipulating PDFs: find a string, remove it and place an image at the former string position. I should have known better as I thought "Well, how hard can that be?” What followed was a deep dive down the rabbit hole, a lot of fiddling with the same tools the author of this gist is using trying to make sense of it all. The final solution work…
> "Well, how hard can that be?” Very hard? I worked on a tool that generated PDFs based on API responses. The tool added charts from the api data. Those PDFs were reports with some hardcoded text. Yesh what a fun ride that was.
Re: So you want to modify the text of a PDF by hand (2020)
#67Semi-related(?) - I created a repository to convert PDF to JPG and back to PDF: https://github.com/whyboris/PDF-to-JPG-to-PDF A government form didn't have editable fields that needed to be filled out. And editing the PDF was impossible (password protection). This was my solution.
Converting to JPG unnecessarily rasterizes text and introduces ugly compression artefacts.
Re: So you want to modify the text of a PDF by hand (2020)
#68You 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…
Re: So you want to modify the text of a PDF by hand (2020)
#69The 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…
Howto https://www.cyberciti.biz/faq/removing-password-from-pdf-on-...
qpdf --decrypt