Mac Terminal change PDF author
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 Acc开发者_运维问答ount on my Mac or use Adobe Acrobat Professional.
- open Automator & create a New Workflow
- search "spec" & add Get Specified Finder Items
- search "meta" & add Set PDF Metadata
- drag-drop the desired PDFs onto the Get Specified Finder Items area
- in the Set PDF Metadata area, update the metadata
- in the upper-right corner, click [Run]
For more detail see the screenshot below:
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
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.
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.
- replace metadata with nulls
exiftool -all:all= CLEAN_file.pdf -overwrite_original
- 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
精彩评论