Solved

Extract pages from varying length PDF

Posted on 2014-11-13
2
373 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 25

Accepted Solution

by:
clockwatcher earned 500 total points
ID: 40442775
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
ID: 40460613
Sorry for the delay, this worked perfectly.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Get Text of Select using class name ***JavaScript Only*** 3 32
Diff of the day 2 43
Javascript image manipulationcrop-image 7 41
Google Chrome: Debugging AJAX call 6 39
PaperPort is a popular document imaging/management product from Nuance Communications (http://www.nuance.com/). It is in widespread use by both individuals (http://www.nuance.com/for-individuals/by-product/paperport/index.htm) and businesses (http:/…
The Adobe PDF proprietary file format is recognized as secure and formulated. But these PDF files are also prone to corruption and any external threat like virus attacks, improper storage can hit PDF file integrity.This type of damages can make cruc…
In this third video of the Xpdf series, we discuss and demonstrate the PDFtoText utility, which converts PDF files into plain text files. Download and install the software.: You may have already downloaded and installed the Xpdf tools while watching…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

751 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