Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Extract pages Adobe Pro X and AcroJS

Status
Not open for further replies.

JasonEnsor

Programmer
Sep 14, 2010
193
0
0
GB
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top