9

I need to change the author of a PDF file on my Mac. I have tried to use grep and sed to accomplish this, but haven't succeeded.

If I open a PDF file in Preview.app and go to Tools > Show Inspector I see "Author: yonatan".

Is it possible to use Terminal.app to change this string?

Thanks

P.S. I know I can create a new User Account on my Mac or use Adobe Acrobat Professional.

joshu
  • 851
  • 2
  • 9
  • 18

4 Answers4

19
  1. open Automator & create a New Workflow
  2. search "spec" & add Get Specified Finder Items
  3. search "meta" & add Set PDF Metadata
  4. drag-drop the desired PDFs onto the Get Specified Finder Items area
  5. in the Set PDF Metadata area, update the metadata
  6. in the upper-right corner, click [Run]

For more detail see the screenshot below:

enter image description here

Jake Berger
  • 5,237
  • 1
  • 28
  • 22
Ryan Schumacher
  • 1,816
  • 2
  • 21
  • 33
16

A better way would be to make use of exiftool, which on Mac you could install with use of Homebrew:

brew install exiftool

You would then edit your metadata in your PDF in the following manner:

exiftool  -Title="Change This Title" -Subject="Fun and PDF" change_my_meta.pdf

Removing metadata

If you only want to remove metadata you can use pdf-redact-tools:

pdf-redact-tools --sanitize untrusted.pdf
Konrad
  • 17,740
  • 16
  • 106
  • 167
  • 7
    It's worth mentioning that `exiftool` does **NOT** remove the metadata - it simply appends a bloc saying "here's the new metadata". The old information is still there. – kiler129 Apr 12 '20 at 07:55
  • 1
    Thanks for the reference to pdf-react-tools! The project is not maintainted anymore, and now suggests to use [dangerzone](https://github.com/firstlookmedia/dangerzone) instead – Greg Sadetsky Jun 02 '21 at 20:56
9

You could use Automator. I dont think that sed is going to work because pdfs are largely binary, or very jumbled at the least. One of the defined 'pdf' actions in Automator is defining metadata, one field which is author. Then call the automator workflow with terminal, or just save the workflow as a droplet.

Jed Schneider
  • 14,085
  • 4
  • 35
  • 46
  • that was awesome thank you! I have never used Automator and didn't know it had exactly what I needed! – joshu Jan 24 '11 at 20:21
3

Having used the proposed methods, I obtained a decrease in quality of my paper (using pdf-redact-tools). For me, using MacOS, the best way to irreversibly remove all metadata from a pdf was performed using both exiftool and qpdf, as follows.

  1. replace metadata with nulls
exiftool -all:all= CLEAN_file.pdf -overwrite_original
  1. linearize the pdf to remove the old metadata (which were replaced with nulls), preventing from restoring of these metadata:
qpdf --linearize file_from_exif.pdf file_out.pdf
David Thery
  • 669
  • 1
  • 6
  • 21