New Feature added to Joel’s PDF Portfolio Utilities: Version 1.7

| 10 Comments

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 now five basic utility scripts bundled into the one, each one demonstrates a different aspect of working with PDF Portfolios or what the API calls “Collections”. To keep things simple, I’ve copied my earlier posts about my Portfolio Utilities to this page. The new feature that allows you to change the initial view of a Portfolio is at the bottom of the post.

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 ( 
	function()
	{
		app.beginPriv(); // Explicitly raise the privilege
		var d = app.newCollection();
		app.endPriv();
		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 “doc.info” 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.

Total Number of Pages:
This script will run through each item in the collection and use the “numPages” method to detect the number of pages in any PDF attachments in the Portfolio then display the total number of pages in PDF files in the Portfolio.

NEW: Set Initial View to Details:
This script will set the Portfolio’s initial view to “Details” and create a splitter bar so that the first file in the Portfolio is showing. This will make the Portfolio look more like the “List with File Preview” layout from Acrobat 9.

Details
Portfolio with initial view set to “Details”.

Windows Installation:

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

Version 9:
%USERPROFILE%\Application Data\Adobe\Acrobat\9.0\JavaScripts

Version 10-10.1.0:
%USERPROFILE%\Application Data\Adobe\Acrobat\10.0\JavaScripts

Version 10.1.1 and higher:
%USERPROFILE%\Application Data\Adobe\Acrobat\Privileged\10.0\JavaScripts

For a fuller explanation as to the change between 10.1.0 and 10.1.1 please see my other article JavaScript Changes for Acrobat X and Reader X, version 10.1.1

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/user/Library/Application Support/Adobe/Acrobat/9.0_x86/JavaScripts/

/Macintosh HD/Users/user/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