Acrobat JavaScript provides a simple and flexible way to automate this task, turning it into an easy one click operation when used from a toolbar button or menu item, or updating whole directories of files when used in a batch process. Metadata can even be added or updated through a server based workflow by using Acrobat JavaScript and PDF.
Metadata information includes the document title, author, keywords, a copyright notice, and any other information the document authors feel is important. Unfortunately, applying metadata manually is time consuming, tedious and error prone. As a result, metadata is often either missing or inadequate on working PDF documents.
Accessing the PDF Metadata from JavaScript
The Acrobat JavaScript DOM (Document Object Model) provides a single, easy to use Document Object property for accessing the PDF metadata, the info property. With this property we can get and set any metadata value, as well as create new metadata entries. Some examples are shown below.
Code:
// Acquire the document title
var strTitle = this.info.title;
// Set the document author to the current users name
this.info.author = identity.name;
// Add a copyright notice. This is a custom metadata entry
this.info.copyright = "Copyright\xA9 " + this.modDate.getFullYear( );
Bookmarks