Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Extract pages from varying length PDF

Posted on 2014-11-13
2
Medium Priority
?
459 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 2000 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

This article focuses on how to remove password security from multiple PDF files by Adobe Acrobat program. Sometimes it is essential to access the stored data items and to print, edit as well as copy content from Portable Document Format files in abs…
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

782 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