Joel’s PDF Portfolio Utilities Updated for Acrobat X


UPDATE: Now works with Acrobat X

For those of you interested in scripting PDF Portfolios with the new Acrobat JavaScript “Collection” Object, I’ve created a few example utility scripts to demonstrate the features of the new object.

There are three basic utility scripts bundled into the one, each one demonstrates a different aspect of working with PDF Portfolios or what the API calls “Collections”.Combine All Open PDF Portfolios:

This script will look at all of the open PDF files to see which are PDF Portfolios meaning the collection object returns a value. Then, it will combine all the open PDF Portfolios into a single new PDF Portfolio that contains all the files and metadata from the sources. This version will not maintain folder structure so it’s best to use on PDF Portfolios that do not contain folders. Creating a new PDF Portfolio through app.newCollection() is a privileged function so you’ll need to wrap it in a trustedFunction to make it work, the code snippet below shows how.

Note: trustedFunction is available only during batch, console and in folder level JavaScripts. Because it is used to elevate the privilege level of the function, you can’t use it from inside a PDF file.

trustedNewCollection = app.trustedFunction ( 
		app.beginPriv(); // Explicitly raise the privilege
		var d = app.newCollection();
		return d;

Copy PDF Document Properties to Portfolio Fields:

This script will run through all of the Data Objects in the collection and,
for every PDF that it finds, will use the new “setFieldValue” method to copy each item in the “” dictionary to a collection metadata field, creating new fields as necessary.

Export Portfolio Metadata to Console:

This script will run through each item in the collection and use the “getFieldValue” method to create a comma separated values stream from the collection metadata. The script will output to the JavaScript console, you can copy the text from there and massage the data in another application if you need to.

Windows Installation:

1. From Windows, select “Start” then “Run”. Depending on your version,  paste the following line into the text box and press enter

%USERPROFILE%\Application Data\Adobe\Acrobat\9.0\JavaScripts

%USERPROFILE%\Application Data\Adobe\Acrobat\10.0\JavaScripts

2. Drag the .js file to that directory

3. Restart Acrobat if it’s running.

Mac Installation:

1. Find your version of the directory below. The red parts of the path will change based on your system, choose the right path for your version.

/Macintosh HD/Users/joelgeraci/Library/Application Support/Adobe/Acrobat/9.0_x86/JavaScripts/

/Macintosh HD/Users/joelgeraci/Library/Application Support/Adobe/Acrobat/10.0_x86/JavaScripts/

2. Drag the .js file to that directory

3. Restart Acrobat if it’s running.

You’ll see a new menu under “Edit” called “Joel’s Portfolio Utilities”

Download Joel’s Portfolio Utilities