×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Extract pages Adobe Pro X and AcroJS

Extract pages Adobe Pro X and AcroJS

Extract pages Adobe Pro X and AcroJS

(OP)
Hi Guys,

I am looking for some help modifying some code I found here Extract pages from a PDF that have certain “text or numbers”?. What i am wanting to do is extract pages based on the search results. I have modified the code slightly but i am unable to get this to work. I think the issue is to do with the while (true) clause.

CODE -->

while (true)
{ 
   p = this.pageNum; 
   searchHits[i] = p; 
   app.execMenuItem("FindAgain");
   if (this.pageNum == p) 
   { 
     break 
   };
   i++;
}; 

but i am struggling to follow the code flow as Adobe and AcroJS are relatively new programming environments to me. It runs for the first result then exists. I think this is due to setting p = this.pageNum; then checking if (this.pageNum == p).

CODE -->

var nStart;
var nEnd;
var nFileName;

var i = 0;
var p = 0;
var ret = 0;
var lastPage = (this.numPages - 1);
var rootFile = this.path.split(".pdf")[0];
searchHits = new Array();

var x = search.query("Accounting","ActiveDoc");

app.alert("Wait for search to complete, then click OK.");

while (ret==0) 
{ 
   ret = this.pageNum;
};

while (true)
{ 
   p = this.pageNum; 
   searchHits[i] = p; 
   app.execMenuItem("FindAgain");
   
   if (this.pageNum == p) 
   { 
      break 
   };
   i++;
};

while (i > -1)
{
    nFileName = rootFile + "_" + i + ".pdf";
    this.extractPages({nStart:searchHits[i], cPath: nFileName});

    i--;  
}; 

Any help would be appreciated

Jason

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close