r/pdf • • 3d ago

Question Help

Hello,

How do you keep the original metadata when modifying a pdf?

thanks

4 Upvotes

14 comments sorted by

1

u/Mental-Pay4132 3d ago

depends on the tool. a lot of editors overwrite the producer and modification date when they save. pdf-lib (which many browser tools use) does it by default, you can turn it off with PDFDocument.load(bytes, { updateMetadata: false }).

if you just want a tool that already does that, the one i build keeps the original producer and dates when you edit, merge, sign etc: tools.nyxiontech.com (free, open source, runs in your browser. disclosure: it's mine). you can check the result afterwards with exiftool or the metadata tool on the same site.

what are you using right now?

1

u/Koop26 3d ago

Nothing at the moment. But I would like the method or the software on Mac so that it is invisible.

1

u/Mental-Pay4132 2d ago

on mac two options:

  1. edit the pdf however you want (preview, acrobat, whatever), then copy the original metadata back with exiftool: exiftool -tagsfromfile original.pdf -all:all edited.pdf. after that the edited file shows the original info. install exiftool with brew install exiftool
  2. or do the edit in the browser tool i mentioned, it works in safari/chrome on mac and doesn't touch the producer or dates in the first place

heads up preview in particular rewrites the producer to something like "macOS Quartz PDFContext", so that's probably what's giving it away

1

u/Koop26 2d ago

Thank you, I’ll try

1

u/StarGeekSpaceNerd 1d ago

One important thing to take note of is that edits to PDFs made with exiftool are reversible.

Exiftool uses the incremental update function of PDFs to update the files (see "Incremental Updates in PDF files", Debenu Foxit). This does not remove any previous data and such changes are reversible. In order to make the changes permanent, the file needs to be re-liniarized by a program such as Adobe Acrobat (see here) or qpdf (run qpdf --linearize --replace-input file.pdf).

1

u/Mental-Pay4132 1d ago

good catch, didn't know exiftool appends an update instead of rewriting the file. thanks for the qpdf line

1

u/hasibulmawla 2d ago

I ran into this same problem when I was editing a PDF for my own notes and the file suddenly looked like a brand new file when I checked it later. I did not expect the dates and other details to change just from saving it, so now I check the file details after I edit anything that matters to me. It is a small extra step, but it saves me from finding out too late that the original information is gone. I wish more editors just left those details alone unless you ask them to change them.

1

u/Koop26 2d ago

Thank you, what do you use?

1

u/Webfiletool_Dev 2d ago

Easiest fix is to copy them back after editing, whatever editor you use. ExifTool does it in one line: exiftool -TagsFromFile original.pdf -all:all edited.pdf (Title, Author, Subject, Keywords, dates and the XMP block). Check the result under File > Properties in your viewer. Some editors also have a "keep document properties" option on save, but copying them back is the most reliable since many tools rewrite Producer and ModDate.