简体   繁体   中英

Extract pages from PDF with javascript in Acrobat Pro

I am trying to create a script that will extract all pages from a pdf document and name them from the number of the pdf (say the pdfs name is 5047.pdf) and then increment the name for every page of the pdf so it produces 5048.pdf, 5049.pdf etc. However my script doesnt do anything.

var filename = 0;
for (var i = 0; i < this.numpages; i++)
this.extractpages

({
nStart: i,
cpath: filename + i + ".pdf"

});

Original link: https://forums.adobe.com/thread/969135

The solution, based on an answer from Adobe's forum:

/* Extract Pages to Folder */

var re = /.*\/|\.pdf$/ig;

var filename = this.path.replace(re,"");
var lastPage=this.numPages-1;
{
    for ( var i = 0;  i < this.numPages; i++ ) 
    this.extractPages
     ({
        nStart: i,
        nEnd: lastPage,
        cPath : filename + "_page_" + (i+1) + ".pdf"
    });
};

This worked for me, it was necessary to extract 2 pages in a row:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM