Live data from Hacker News

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

gist.github.com

51–60 of 103 posts

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

#51
post #31

Earlier quoted context omitted.

Aren’t the blend modes supported just the Porter-Duff compositing modes? You might think that’s overkill, but it’s a really good mapping of what other rendering pipelines offer and it can really help reduce the work to produce a PDF.

The original Porter-Duff compositing operators don’t cover Photoshop-style blending. Here’s a link with pictures: http://ssp.impulsetrain.com/porterduff.html The Porter-Duff operators are appealingly rigorous and easy to implement because they’re simply the possible combinations of a simple formula. But many of these operators are not very useful either. The Photoshop blending modes are practically the opposite: they…

An yes. I had forgotten that the blend modes added an arbitrary function that goes beyond the original model.

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

#53
post #38

Anybody trying to do this is missing the point of PDF: It’s a page-description format and therefore only represents the marks on a page , not document structure . One should not attempt to edit a PDF, one should edit the document from which the PDF is generated.

I'll stop trying to edit PDFs when people stop sending me PDFs that I want to edit. Somehow it became "unprofessional" to just send meant-to-be-editable documents around for everyone to enjoy, so this is where we end up...

Yes, This is exactly the source of the problem. Otherwise editing would rarely be a problem or even needed. And for this it is extremely ill suited. I remember having printed a document, typed by hand and scan it back in a pressing situation. It felt bizantinely complicated and equally frustrating.

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

#54

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…

Howto https://www.cyberciti.biz/faq/removing-password-from-pdf-on-...

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

#56
Great post. I've spend a lot of time reading through the PDF specification over the last ~5 years while building DocSpring [1], and I still feel like I've barely scratched the surface. qpdf is a great tool. One of my other favorites is RUPS [2], which really lets you dig into the structure of a PDF.

[1] https://docspring.com

[2] https://github.com/itext/i7j-rups

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

#57

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.

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

#58
Semi-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.

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

#60

PDF 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.

Post reply on HN