Script to create portfolio from multiple PDF files
Copy link to clipboard
Copied
Search didn't turn up anything current, so asking here. Is there a recommended method for automatically creating a PDF portfolio from several known PDF files. I have a static PDF file and several reports that are generated every month. I'd like to somehow script combining these PDF files into a single new PDF portfolio every month. It doesn't look like Distiller does that, and it doesn't look like Acrobat Pro's Action Wizard will do that either. And I couldn't figure out how to control Acrobat with PowerShell or similar to feed it commands. Any suggestions or pointers on how to proceed?
Copy link to clipboard
Copied
Does it have to be a Portfolio? Why not a regular PDF file?
PS. If you found something that worked in the past there's a good chance it will work now too, maybe with some minor modifications.
Copy link to clipboard
Copied
Portfolio is a user requirement, because they've been doing it that way for many years. They are currently assembling the PDF Portfolio manually using Acrobat Pro every month once the reports are generated, combining the static portion with the reports. The legacy report writer engine is the old Oracle Forms and Reports, and for the time being is getting swapped for something that can be maintained, with the plan in the next year to move to a more modern low-code application development platform for the entire system.
The users have seen prototypes of PDF files with bookmarks as an alternative and didn't like it, because they couldn't easily export a single report from the big PDF file like they can with a PDF Portfolio, which is apparently a requirement
Copy link to clipboard
Copied
After doing some additional research, it looks like this is probably not possible with Acrobat, in part due to Adobe's licensing restrictions on Acrobat. Specifically, Adobe doesn't permit automation of a licensed copy of Adobe Acrobat, except using Action Wizard, and automated tasks of Acrobat must be initiated by users. So that leaves probably writing a custom application that can be invoked as the final step of the report generation process to assemble the PDF Portfolio. Does anyone have experience using Datalogics' Adobe PDF Library product? It seems like gross overkill for this one simple task!
Alternatively, if I set up the static PDF file so when a user opens it, are there enough capabilities in the JavaScript for Acrobat API to bring in several reports to a PDF Portfolio when a user opens the file? Going through the JavaScript for Acrobat API reference didn't make it clear if newCollection, followed by some addField calls, and then a saveAs will do the trick (I haven't programmed in a long time)
Copy link to clipboard
Copied
A Portfolio is actually a fancy version of what's called a collection. You can create collections using Acrobat JavaScript.
Here's the reference entry for the Collection object property of a pdf document:
You use "app.newCollection()" to create a new PDF collection.
Use the Acrobat JavaScript Reference early and often
Copy link to clipboard
Copied
Note that addField doesn't add files to the Portfolio, only "fields", which are not the same as form fields, either, but kind of Portfolio metadata.
Copy link to clipboard
Copied
Thanks for clarifying that detail. Is there a way to add files to the PDF Portfolio (collection) in Javascript, whether individual PDF or other file types? The only methods I see for dealing with collections are addField, getField, and removeField. If addField doesn't add files to the collection, is there some other method I use for that? Or is it even possible to create and add files to a collection with Javascript in Acrobat?
Copy link to clipboard
Copied
The files in a Portfolio are PDF file attachments, which are called Data Objects in the JS model. To add a files into the Portfolio you add data objects to the PDF.
Use the Acrobat JavaScript Reference early and often

