Solved

Extract pages from varying length PDF

Posted on 2014-11-13
2
326 Views
Last Modified: 2014-11-23
Hi, I need to extract select blocks of pages from 300+ individual PDF files on a daily basis, creating similarly named files in another folder. I have a Javascript action in Adobe Acrobat Pro which works well for one extract, but I have been unable to modify it to extract the last three pages of each PDF when the page number count varies. The PDF's can be 6 or 7 pages in length. What I need is a script to extract the last three pages irresepective of the number of pages in the PDF. Here is the script which works well for the mid section of the PDF document:

/* Extract pages to folder */

// Regular expression used to acquire the base name of file

var re = /\.pdf$/i;

// filename is the base name of the file Acrobat is working on

var filename = this.documentFileName.replace(re,"");

try {
      this.extractPages({
      nStart: 1,
      nEnd: this.numPages-3,

      cPath: "/C/Temp/ProcessFolder/System_Processing/_02_extract_p2_to_p4/"+filename+"_" + "P2_P4" +".pdf"

                  });        
} catch (e) { console.println("Aborted: " + e) }

I would appreciate any help you can offer, I've been going nuts trying to work this out (Javascript newbie)

Thanks
0
Comment
Question by:jonlake
2 Comments
 
LVL 25

Accepted Solution

by:
clockwatcher earned 500 total points
Comment Utility
Just glancing but what you posted looks like it would extract from the first page to the third from the last page.  I don't have Acrobat Pro around to try but does changing it to this not work?
try {
       this.extractPages({
       nStart: this.numPages -3,
       nEnd: this.numPages,

       cPath: "/C/Temp/ProcessFolder/System_Processing/_02_extract_p2_to_p4/"+filename+"_" + "P2_P4" +".pdf"

                   });         
 } catch (e) { console.println("Aborted: " + e) }

Open in new window

0
 

Author Closing Comment

by:jonlake
Comment Utility
Sorry for the delay, this worked perfectly.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Power PDF (http://www.nuance.com/for-business/document-imaging-and-scanning/power-pdf-converter/index.htm) is the newest product from the Document Imaging division of Nuance Communications (http://www.nuance.com/). It is available in two editions — …
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now