Copy link to clipboard
Copied
I am trying to find a formula that will extract from page 3 up to the last but two pages of a pdf. I then want to save the eo xtracted file and save it to a specific file on the C drive using the original file name with a prefix of INNER. All I have so far is the formula for extracting the pages -
this.extractPages(2, this.numPages-3 );
Copy link to clipboard
Copied
This code should do the trick:
var oldDoc = this;
var newDoc = oldDoc.extractPages(2, oldDoc.numPages-3 );
newDoc.saveAs(oldDoc.path.replace(oldDoc.documentFileName, "INNER " + oldDoc.documentFileName));
Copy link to clipboard
Copied
Sorry, I've noticed you want to save it to a pre-defined folder. The code above will save the new file to the same folder as the original.
Let's say you want to save it to C:\Temp\. Use this code to do that:
var oldDoc = this;
var newDoc = oldDoc.extractPages(2, oldDoc.numPages-3 );
newDoc.saveAs("/c/temp/INNER " + oldDoc.documentFileName);
Copy link to clipboard
Copied
Thank you so much. This works like a dream.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now