Rework Adobe Javascript code to use array


Rework Adobe Javascript code to use array



Need to know how to modify Javascript to use array instead of single variable in Adobe Acrobat.



Instead of a single string, I want to be able to use a TXT or CSV file, and extract all the strings stored in that TXT or CSV file. I think this means storing results in arrays, but I use SQL on a daily basis, not Javascript.


// Iterates over all pages and find a given string and extracts all
// pages on which that string is found to a new file.

var pageArray = ;
var stringToSearchFor = "Total";

for (var p = 0; p < this.numPages; p++) {
// iterate over all words
for (var n = 0; n < this.getPageNumWords(p); n++) {
if (this.getPageNthWord(p, n) == stringToSearchFor) {
pageArray.push(p);
break;
}
}
}

if (pageArray.length > 0) {
// extract all pages that contain the string into a new document
var d = app.newDoc(); // this will add a blank page - we need to
remove that once we are done
for (var n = 0; n < pageArray.length; n++) {
d.insertPages({
nPage: d.numPages - 1,
cPath: this.path,
nStart: pageArray[n],
nEnd: pageArray[n],
});
}

// remove the first page
d.deletePages(0);

}









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Comments

Popular posts from this blog

paramiko-expect timeout is happening after executing the command

Export result set on Dbeaver to CSV

Opening a url is failing in Swift