Solved

Update PDF Meta Data

Posted on 2014-01-20
2
542 Views
Last Modified: 2014-01-24
I have a few hundred PDF's that I want to place the file name into the Title Meta Data.

Is there anything I can use to auto update rather than opening updateing and saving each file?
0
Comment
Question by:jdr0606
2 Comments
 
LVL 51

Accepted Solution

by:
Joe Winograd, EE MVE earned 500 total points
Comment Utility
The PDF Toolkit (PDFtk), an excellent (free!) product that I've been using for many years, can do this. It comes in both command line and GUI versions. The command line version is called PDFtk Server and may be downloaded here:
http://www.pdflabs.com/tools/pdftk-server/

Don't be misled by "Server" in the name. I don't know why they called it that, but it's just an executable (pdftk.exe, with a supporting DLL, libiconv2.dll) that runs on XP, Vista, W7, and W8 (it does not have to run on a "server" OS...it also runs on Mac, but I've never used it on that).

The manual for it is here:
http://www.pdflabs.com/docs/pdftk-man-page/

You want to look at the "dump_data" option, which reports on the metadata fields, and then the "update_info" option, which changes the metadata fields. Here's an example of what the "dump_data" file looks like (trimmed a little) from a PDF posted at a public site:

InfoBegin
InfoKey: Author
InfoValue: SE:W:CAR:MP
InfoBegin
InfoKey: Producer
InfoValue: Adobe LiveCycle Designer ES 9.0
InfoBegin
InfoKey: Creator
InfoValue: Adobe LiveCycle Designer ES 9.0
InfoBegin
InfoKey: Keywords
InfoValue: Fillable
InfoBegin
InfoKey: ModDate
InfoValue: D:20131129152708-05'00'
InfoBegin
InfoKey: Accessibility
InfoValue: structured; tagged
InfoBegin
InfoKey: Form fields
InfoValue: fillable
InfoBegin
InfoKey: Title
InfoValue: 2013 Form 1040
InfoBegin
InfoKey: Subject
InfoValue: U.S. Individual Income Tax Return
InfoBegin
InfoKey: CreationDate
InfoValue: D:20131129152618-05'00'
PdfID0: defb5d400969464b86df15a6db48b551
PdfID1: 7b051e02238abdf258b624ae7615f61e
NumberOfPages: 2

It sounds as if your interest is in the Title field, or perhaps you mean the Subject field. For both cases, the relevant lines for you are these:

InfoBegin
InfoKey: Title
InfoValue: this is the new title for your file
InfoBegin
InfoKey: Subject
InfoValue: this is the new subject for your file

Simply put those lines (3 or 6, depending on what you want to change) in a text file called, for example, <newtitle.txt> and execute this command:

pdftk oldfile.pdf update_info newtitle.txt output newfile.pdf

This assumes that your input/old/source file is <oldfile.pdf> and your output/new/destination file is <newfile.pdf>. The file names may, of course, be whatever you want, and they may be fully qualified with drives/paths.

If you want to see PDFtk used in a real-world app, including a call with the "dump_data" option, see this EE article:
http://www.experts-exchange.com/Software/Misc/A_11211-How-To-Split-Rename-Move-a-Batch-of-PDF-Files-Based-on-Contents-of-the-Files.html

It is a long article and program, but you may focus just on the usage of PDFtk. The tool has worked perfectly in all programs I've written that call it. Regards, Joe
0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
Comment Utility
If you have Adobe Acrobat Pro, you can use an Action to do that. To create an action that puts the filename into the Title document property, you would do the following:

Select Tools>Action Wizard>Create New Action

On the next dialog, expand the "More Tools" category and double-click on "Execute JavaScript" (or select it and click on the arrow button in the middle of the dialog to move it to the right side).

Now click on "Specify setting" under "Execute JavaScript" on the right side of the dialog. This will bring up the JavaScript editor. Here you would use the following script:

this.info.Title = this.documentFileName; 

Open in new window


Now expand the "Save & Export" category on the left side and bring the "Save" function over to the right. Open up the settings and modify them according to your needs (e.g. save under the same filename, add a prefix or a suffix, ...

You can run the action on e.g. all files in a certain directory and update them all at once.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
If your app took Google’s lash recently, here are the 5 most likely reasons.
This video demonstrates basic masking and how to edit the mask to reveal the desired image.
Video by: Tony
This video teaches viewers how to export a project from Adobe Premiere Pro and the various file types involved.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now