Solved

Extract pages from varying length PDF

Posted on 2014-11-13
2
397 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Have you ever come up with a need of emailing only few pages of PDF file to one of yourfriend or colleague, instead of whole Adobe file? If yes, then surely you have face problems in doing that! Read this section as I have suggested multiple solutio…
In a previous article published here at Experts Exchange, Signature Image with Transparent Background (http://www.experts-exchange.com/Web_Development/Document_Imaging/A_12380-Signature-Image-with-Transparent-Background.html), I explained how to cre…
In this first video of the three-part Xpdf series, we introduce and describe Xpdf, a library containing nine command line utilities that perform various functions on PDF files. We show where the library is located and how to download it, discuss its…
In this video, we show how to convert an image-only PDF file into a PDF Searchable Image file, that is, a file with both the image (typically from scanning) and text, which is created in an automated fashion with Optical Character Recognition (OCR) …
Suggested Courses

617 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