Hi,
I've slightly modified a script from another post here. It is mostly working but I need to know how to change two things about it. Not knowing a lot about scripting any help would be appreciated.
Currently it is setup to extract pages in 100 page increments. What I need to know is how to make it get the last group of pages when the overall page count is not divisible by 100.
Also need to base the new file name on the original document file name the pages are being extracted from. So instead of using the _Extract shown below in var filename it would use the name of the source file minus the extension.
So if I had a file named acrobat pages.pdf with 420 pages the result would be 5 extracted files with the first 4 containing 100 pages and the 5th containing 20 pages. The files would be named:
0001_acrobat pages.pdf
0002_acrobat pages.pdf
0003_acrobat pages.pdf
0004_acrobat pages.pdf
0005_acrobat pages.pdf
Thanks for any direction that you can provide.
Below is the script I'm currently working with.
/* EXTRACT IN 100'S */
var filename = "_Extract";
var nihe=1;
try {
for ( var i = 0; i < this.numPages; i+=100)
this.extractPages
({
nStart: i, nEnd: i + 99,
cPath: util.printf("%04d",i/100+1) +filename +".pdf"
});
} catch (e) { console.println("Aborted: " + e) }
var lastPage = i + 99;
if (lastPage>=this.numPages)
lastPage = this.numPages-1;
var filePath = util.printf("%04d",i/100+1) + "_" + this.documentFileName;
this.extractPages ({
nStart: i,
nEnd: lastPage,
cPath: filePath
});
- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com