JasonEnsor
Programmer
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.
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).
Any help would be appreciated
Jason
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