Skip to main content
Participating Frequently
August 6, 2022
Question

How can I search multiple phrases within a pdf by javascript?

  • August 6, 2022
  • 1 reply
  • 1675 views

I have two fields in a PDF.

I write a phrase in one field and an article in the second field.

 

How can I display the number of repetitions of the phrase in field one, somewhere in the PDF?

I have to use javascript for this.

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
August 6, 2022

There's no simple way of doing it, as JavaScript can only read one word at a time from a page, and has no built-in search command it can use. You would need to read the entire contents of the file to a string variable, and then use a Regular Expression to search that string for matches of the phrase you want to look for. If the file is very large this might be problematic to do, though.

Mahmood_MAuthor
Participating Frequently
August 8, 2022

No problem, please write the javascript code for one word, if possible and I will expand it.

try67
Community Expert
Community Expert
August 8, 2022

Sure thing. Send me a private message and we could discuss the price for that.