Skip to main content
Participant
January 23, 2023
Answered

Automatically search PDF and add tooltips to key text

  • January 23, 2023
  • 2 replies
  • 926 views

I want to check if what I am after is even possible. In short, I want to create a local JSON file that is essentially a dictionary that takes a word and the assoiated definition (eg: {word1 : definition, word2 : definition...}

 

Then I want to be able to scan a PDF and automatically create a form for each keyword that is a tooltip/popup with the definition. 

 

Very new to Acrobat, so am struggling to know where to start (or if it is even possible?). I'm assuming a document level JS that reads in the JSON file, but not sure how to automatically/dynamically create tooltips.

This topic has been closed for replies.
Correct answer try67

Yes, that will work. Basically, you would need to use a loop to search all the words in all the pages of the file (using getPageNthWord and getPageNumWords) to look for matches for the items in the list (which you can read using readFileIntoStream of the util object), and then add a (transparent) button over each one with the tooltip text (using addField).

This is not a trivial task, though, especially if the search terms are more than one word, and/or the file is very long, as I've said earlier.

 

I've actually developed a (paid-for) tool that does exactly that: https://www.try67.com/tool/acrobat-add-tooltip-text-to-key-words-or-phrases

 

2 replies

try67
Community Expert
Community Expert
January 23, 2023

Yes, this is possible, but in order to read the contents of an external file automatically (without selecting it each time) a script file will have to be installed on each computer where this should work. Is that possible in your case?

Also, this might seriously slow down the process of opening the file, depending on how long it is, and how long (and complex) the list of search terms are.

Participant
January 23, 2023

Thanks! So I would only need to run this on my own machine, and then share the output PDF (ie: after the tooltips have been added) with others who only have acrobat reader (not pro); I'm guessing this still OK? Could you point me in the direction of where to start? Or some related threads? I didn't have much luck when I searched the forum. 

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
January 23, 2023

Yes, that will work. Basically, you would need to use a loop to search all the words in all the pages of the file (using getPageNthWord and getPageNumWords) to look for matches for the items in the list (which you can read using readFileIntoStream of the util object), and then add a (transparent) button over each one with the tooltip text (using addField).

This is not a trivial task, though, especially if the search terms are more than one word, and/or the file is very long, as I've said earlier.

 

I've actually developed a (paid-for) tool that does exactly that: https://www.try67.com/tool/acrobat-add-tooltip-text-to-key-words-or-phrases

 

Participant
January 23, 2023

I'm working with Acrobat pro 2022.003.20258