Joel's PDF Portfolio Utilities
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 four basic utility scripts bundled into the one, each one demonstrates a different aspect of working with PDF Portfolios or what the API calls "Collections".
UPDATE: 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;
}
)newPortfolio = trustedNewCollection();
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.
Set Portfolio Initial View:
This script will create a fly-out menu that allows you to set the "initialView" of the collection to "Tile" (Basic Grid), "Detail" (List View), or "Hidden" which will show the cover sheet rather than the Flash-based Portfolio interface.
These are just examples and I haven't done anything that anyone could rightly call testing so use these to learn the new parts of the API not for actual work.
Windows Installation:
1. From Windows, select "Start" then "Run". Paste the following line into the text box and press enter
%USERPROFILE%\Application Data\Adobe\Acrobat\9.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.
/Macintosh HD/Users/joelgeraci/Library/Application Support/Adobe/Acrobat/9.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 "Document" called "Joel's Portfolio Utilities"
|
|
Comments (1) |
|

Comments
I'm trying to find/write a utility that will allow me to scan a folder containing PDFs and return which of them is a PDF Portfolio (or package). Any ideas on where I might start?
Thanks a lot!
[Joel's response]
William: Great question. My first thought was to use Acrobat's Batch feature but as it turns out, when you try to run a batch JavaScript against a PDF Portfolio, the JavaScript runs on the items in the Portfolio rather than the Portfolio itself.
So - at this time, I can't think of a way to accomplish what you are trying to do.
Posted by: William Gordon | October 19, 2009 10:24 AM