Copy link to clipboard
Copied
Despite the text strings being recognized as text, the searchForText method is unable to locate them. The error message "TypeError: searchResults is undefined" is displayed. I would be grateful if you could provide a corrected code snippet.
Copy link to clipboard
Copied
I'm not familiar with this method. Can you post your full code, please?
Copy link to clipboard
Copied
Thanks for replying.
I will send you the code I have created.
var targetTexts = ["LD", "MBR", "BR", "BR1", "BR2"];
var grayColor = color.rgb(192, 192, 192);
for (var pageNum = 0; pageNum < this.numPages; pageNum++) {
var page = this.getPage(pageNum);
page.searchForText({
text: targetTexts.join("|"),
caseSensitive: false,
wholeWordsOnly: true,
}).forEach(function(searchResult) {
searchResult.textColor = grayColor;
});
}
Copy link to clipboard
Copied
Don't know where you got this code from (ChatGPT?), but it's not valid code for Acrobat JS.
There's no getPage method, nor a searchForText method.
Copy link to clipboard
Copied
When you use the script in Acrobat you will get this error:
TypeError: color.rgb is not a function