Copy link to clipboard
Copied
I am looking to search a pdf using javascript to find a certain number, the index of a number or anything that would get a number string on a PDF. The closest thing I have found is "this.getPageNthWord" but that cannot get numbers. Any help would be appreciated.
Copy link to clipboard
Copied
OK. Well, this code will print out all the words in the file with a digit in them (so even "1a" or "abc3xyz"):
for (var p=0; p<this.numPages; p++) {
var numWords = this.getPageNumWords(p);
for (var i=0; i<numWords; i++) {
var word = this.getPageNthWord(p,i,true);
if (/\d/.test(word)) console.println(word);
}
}
Copy link to clipboard
Copied
in the future, to find the best place to post your message, use the list here, https://community.adobe.com/
<moved from using the community>
Copy link to clipboard
Copied
What happens when you use this function?
Copy link to clipboard
Copied
Numbers in a page, words on a page, symbols on a page. These are all characters of the same kind. getPageNthWord gets groups of characters, combined by guesswork into "words". What difficulty do you face reading strings of digits as numbers?
Copy link to clipboard
Copied
I have a string of numbers on the page that was imported from using prepare forms "topComponent" feature. I would like to get the number string from off the page and use it in my JavaScript but when I use "this.getPageNthWord" it just skips over the number string completely.
Copy link to clipboard
Copied
What do you want to do with these numbers, once they are found?
Copy link to clipboard
Copied
add them to a populated email but I know how to do that already
Copy link to clipboard
Copied
OK. Well, this code will print out all the words in the file with a digit in them (so even "1a" or "abc3xyz"):
for (var p=0; p<this.numPages; p++) {
var numWords = this.getPageNumWords(p);
for (var i=0; i<numWords; i++) {
var word = this.getPageNthWord(p,i,true);
if (/\d/.test(word)) console.println(word);
}
}
Copy link to clipboard
Copied
It worked great! Thanks so much!

