Live data from Hacker News

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

gist.github.com

81–90 of 103 posts

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

#83
1. The PDF format is wildly overcapable compared to the majority of actual use (view text, tables and images).

2. The number of user devices with unpatched PDF readers is likely large.

3. The system of paywalled scientific knowledge drives millions of students and researchers to get their science PDFs from scihub and libgen pirate sites hosted in former Soviet countries, sometimes over http (not https).

These three facts combine to a huge vulnerabilty space.

On the flipside a sane and open PDF replacement format that also offered reduced file size could gain many users quickly by convincing scihub and libgen to convert and offer their files in the new format to cut costs and shorten download time, with reduced vuln as a positive externality.

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

#84
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...

Its that age old problem where people send documents, that need to be edited by the recipient in a structured way.

Same thing goes on with Word docs being sent out, formatted in a particular way like PDF's, ie a questionnaire, and the recipient needs to edit said document and then send it back.

HTML forms are other examples.

All these years later, still no globally standard way to achieve this quickly and easily, and yet it would seem perfect for the Open Source world to tackle.

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

#85
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.

> The weird thing to me is people using a distribution format as an original source.

Every distribution format will inevitably end up being used as a source; as the originals get lost in the mists of time.

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

#86
post #23

Earlier quoted context omitted.

To be fair, if you wanted to stop copying of text it would be easiest just to drop the ToUnicode mapping against the fonts and then it’s a manual process for people to recreate them.

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.

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

#87
20 years ago, I worked as the plate person at a newspaper: we had two million dollar kodak plate "printers" -- printer is the wrong word, but the emulsion on the plates could be hit by UV light and dissolved in a chemical bath iirc. Regularly, the kodaks would fail, and my boss would go into the postscript (or maybe eps) files manually, change a header or some other malformed bit that came from the layout software that sent us the files, and all would be well again (our giant German offset web press ran linux, btw)

I think his name was Bill. He took me, a 17 year old, to a Sigur Ros concert. Great dude. Wow two stories that don't involve pdfs!

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

#88

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.

One challenge is marking up corrections that need to go back to the source document. I get proofs from a typesetter, and I need to mark it up for them to fix. I can't change the pdf text, because the typesetter won't see that. Acrobat's markup tools aren't terrible, but they aren't quite what I could do in the days of paper and red pencils. Unless I use the 'pencil' tool in Acrobat. I'd like to see that improved.

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

#89
post #78
post #5

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…

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

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

#90
post #39

LibreOffice can open and edit PDFs. Last time I tried it was really good. Not sure what limitations are there.

For me it always seems to change the font from whatever was built into the PDF (rendered just fine in any PDF reader) to a random system font which completely breaks the spacing, making different parts of the document overflow into each other

That is always going to be a problem with editing pdfs with embedded font information--if you can't match the font, you will screw up the layout. Even if you can match the font, you'll probably still screw up the layout.
Post reply on HN