How to automate extracting pages from a PDF using AppleScript and Acrobat Pro?

微笑、不失礼 提交于 2019-12-04 14:10:59

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

ClearBlueSky85

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

Adobe Acrobat Pro - Edit Action

You can create a new action that prompts the user to select a folder of pdf files to process. Then you can add JavaScript execution that searches for the pdf file names and extractPages function to extract all the pages from a PDF

Adobe Acrobat Pro - JavaScript

The following will extract all of the pages into separate PDFs. It appends a suffix on the end with each sheet number. It pads 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 slices out to take however many last digits of the string depending on how many sheets you typically 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 to separate pdf's (something wrong with loop?)

How can I create a Zerofilled value using JavaScript?

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!