Live data from Hacker News

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

gist.github.com

41–50 of 103 posts

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

#42

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.

PDF does support incorporating information about the logical document structure, aka Tagged PDF. It’s optional, but recommended for accessibility (e.g. PDF/UA). See chapters 14.7–14.8 in [1].

[1] https://opensource.adobe.com/dc-acrobat-sdk-docs/pdfstandard...

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

#43

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.

"should not" is meaningless here, because in the real world there are tons of situations where people want you to edit PDF, one way or another

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

#44
This brings back horrible memories of working with large complex maps back in the 2000s. Having various CAD and GIS applications generate messy, inefficient spaghetti-coded PDF outputs - then bouncing those PDFs around the Adobe apps of the time, to add effects and other prettifications not available in the mapping apps.

It would reach the point where things would start to break, and .... "good times were had, by all".

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

#45
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 worked better than I thought while at the same time felt incredibly wrong.

I'm very thankful for all the (probably painful) work that went into those open source PDF tools.

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

#46
post #37
post #10

Earlier quoted context omitted.

It is a shame Adobe designed a format so hard to work with that people are amazed when someone accomplishes what should be a basic task with it. Their design philosophy of creating a read-only format was flawed to begin with. What's the first feature people are going to ask for??

> 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)

#47
> I didn't see an obvious open-source tool that lets you dig into PDF internals

That’s a matter of the toolset. I program C#, and I have good experience with that open source library: https://www.nuget.org/packages/iTextSharp-LGPL/ It’s a decade old by now, but PDF ain’t exactly a new format. That library is not terribly bad for many practical use cases. Particularly good when you only need to create the documents as opposed to editing them, because for that use case you’d want to use an old version of the format anyway, for optimal compatibility.

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

#49
post #37

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

I believe Illustrator format is very similar to PostScript.
Post reply on HN