2

I am trying to make a file metadata (PDF) identical to another file (PDF). I am on a MacBook Pro and I have installed the exiftool. While the exfitool is mostly able to do the job, there are few lines that I don't want in the destination file (that don't exist in the source file).

To be more specific:

Creator Tool: ...
XMP Toolkit: ...
Metadata date: ...

I can leave the Creator Tool but I must delete the XMP Toolkit line and need to either modify or delete the Metadata date. What could I do? Do you have maybe another tool to suggest?

Elegancia
  • 29
  • 3

2 Answers2

0

You can use cpdf -print-metadata in.pdf > metadata.xml to extract the XMP metadata to a file. Then you can delete the bits you don't like, and use cpdf -set-metadata metadata.xml in.pdf -o out.pdf to inject the new metadata back in. You can find the free version of cpdf here:

https://community.coherentpdf.com

If your file also has old-style (non-XMP) metadata, you can use some of the other functions in Chapter 11 of the manual:

https://www.coherentpdf.com/cpdfmanual.pdf

johnwhitington
  • 2,308
  • 1
  • 16
  • 18
0

Using exiftool, you command would be

exiftool -TagsFromFile Source.pdf -All:All --CreatorTool --MetadataDate -XMPToolkit= target.pdf

This will copy all the tags in Source.pdf to the exact same locations, exluding Creator and MetadataDate. It also deletes the XMPToolkit which exiftool would write by default.

It will not copy any custom tags. For example, in Adobe Reader, any metadata created under Document Properties->Custom tab will not be copied by exiftool, as exiftool needs a definition so it knows how to write a tag.

Finally, all edits exiftool makes are reversible. See 3rd paragraph on the PDF Tags page. This is because exiftool uses incremental updates in PDFs. See Foxit's Incremental Updates in PDF files page. To make the changes permanent, the file must be re-linearized. This can be done using qpdf and probably some other PDF tools

qpdf --linearize in.pdf out.pdf

StarGeek
  • 4,948
  • 2
  • 19
  • 30
  • This command can also be done in batch, but it would require knowing the location of the source and target filenames. – StarGeek May 16 '23 at 20:12