These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

batch Extracting first page or Delete other pages

JoniSmith
Registered: Oct 6 2011
Posts: 1

Hi all,
 
I know practically nothing about javascript, but from other posts like Thom Parker's tutorial (http://acrobatusers.com/tutorials/extracting-pages-pdf-acrobat-javascript), I know I can do what I need. Only I'm having trouble tweaking the script to suit my purposes.
 
I have several pdfs in a folder. I only need the first page for each. I don't care if I extract that first page, or delete all the others.
 
I've tried putting this in a batch process:
 
this.extractPages(0);
 
but it creates the temp file, and I don't get how to retain the filename based on the tutorial.
 
I tried this:
 
this.extractPages(0,5);
var cPath = oNewDoc.path.replace(oNewDoc.documentFileName,cFlName);
oNewDoc.saveAs(cPath);
 
but it doesn't work.
 
I also tried to modifying the loop and using the console, but I obviously don't know what I'm doing, so I'm getting an error.
 
Can someone tell me how to create a batch script that does this? Thank you.
 
I'm using Acrobat Pro 9.4.6

My Product Information:
Acrobat Pro, Windows
try67
Expert
Registered: Oct 30 2008
Posts: 2398
You were almost there... but actually deleting the other pages is easier than extracting just the first one.
Here's the code for that:

if (this.numPages>1)
this.deletePages({nStart: 1, nEnd: this.numPages-1});

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com