Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Extract pages from varying length PDF

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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

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…
This article discusses how to create an extensible mechanism for linked drop downs.
Sometimes we receive PDF files that are in the wrong orientation. They may be sideways or even upside down. This most commonly happens with scanned or faxed documents. It is possible to rotate the view of these PDFs with the free Adobe Reader produc…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

721 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