需要知道如何修改Javascript以使用数组而不是Adobe Acrobat中的单个变量。
我希望能够使用TXT或CSV文件而不是单个字符串,并提取存储在该TXT或CSV文件中的所有字符串。我认为这意味着将结果存储在数组中,但是我每天都使用SQL,而不是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);
}