How to automate page extraction from PDF using AppleScript and Acrobat Pro?

I'm new to AppleScript, but I'm trying to create a script that will go through all the PDF files in a folder that extracts pages into separate files. My plan is to use a combination of Automator and AppleScript.

My AppleScript so far:

tell application "Adobe Acrobat Pro" open theFile set numPages to (count active doc each page) --execute the extraction here end tell 

The command in Acrobat Pro is under Options > Extract Pages... , where I can specify a range of pages and extract them to separate the files. However, I cannot find a way to do this using the Acrobat Pro dictionary in AppleScript.

There is an execute command that executes a menu item, but I cannot make it work (I am also not sure about the use of syntax, i.e. execute "Options:Extract Pages..." ?). Any help on this?

+3
pdf applescript acrobat automator
Sep 04 '13 at 18:17
source share
2 answers

I think you can do this completely with Automator without the need for AppleScript or Adobe software. The PDF to Images action splits a multi-page .PDF file into separate .PDF files, one per page:

enter image description here

+3
Sep 04 '13 at 20:53 on
source share

You can use Adobe Acrobat Pro. Here is an example using Adobe Acrobat Pro XI. It uses Acrobat "Actions" (formerly called "Batch Processing") with custom JavaScript.

Adobe Acrobat Pro - Change Action

You can create a new action, prompting the user to select a folder of pdf files for processing. You can then add JavaScript execution that looks for PDF and extractPages file names to extract all pages from PDF

Adobe Acrobat Pro XI - Edit Action

Adobe Acrobat Pro - JavaScript

Next, all pages will be extracted into separate PDF files. It adds a suffix at the end with each sheet number. It fills the sheet number with zeros based on the method described in the links, which basically adds a bunch of zeros in front, and then only fragments to take as many last digits of the string as you like, depending on how many sheets you usually have.

 /* Extract Pages to Folder */ var re = /.*\/|\.pdf$/ig; var filename = this.path.replace(re,""); { for ( var i = 0; i < this.numPages; i++ ) this.extractPages ({ nStart: i, nEnd: i, cPath : filename + "_s" + ("000000" + (i+1)).slice (-3) + ".pdf" }); }; 

References

JavaScript for Acrobat API Reference> JavaScript API> Doc> Doc Methods> extractPages

Extract pages for a separate PDF (is there something wrong with the loop?)

How to create a Zerofilled value using JavaScript?

How to output integers with leading zeros in JavaScript [duplicate]

+1
May 28 '15 at 17:52
source share



All Articles