• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

JavaScript search or find or get a number or number string on a page.

New Here ,
Dec 08, 2022 Dec 08, 2022

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. 

Views

2.2K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Dec 08, 2022 Dec 08, 2022

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);
	}
}

Votes

Translate

Translate
Community Expert ,
Dec 08, 2022 Dec 08, 2022

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>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 08, 2022 Dec 08, 2022

Copy link to clipboard

Copied

What happens when you use this function?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 08, 2022 Dec 08, 2022

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 08, 2022 Dec 08, 2022

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. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 08, 2022 Dec 08, 2022

Copy link to clipboard

Copied

What do you want to do with these numbers, once they are found?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 08, 2022 Dec 08, 2022

Copy link to clipboard

Copied

add them to a populated email but I know how to do that already 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 08, 2022 Dec 08, 2022

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);
	}
}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 08, 2022 Dec 08, 2022

Copy link to clipboard

Copied

LATEST

It worked great! Thanks so much! 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines