Skip to main content
Participant
February 24, 2020
Question

Count highlighted words and phrases

  • February 24, 2020
  • 2 replies
  • 3513 views

Has anyone created an action, similar to the find and highlight, from the masterful Lori Kassuba, to create a count of the number of highlighted words in a document?

 

I need to create a pdf, highlight a set of words/phrases from a list and know how many occurrences, preferably unique (that is to say, the first occurrence of each unique word/phrase highlighted) exist.

 

Failing that, if anyone could point me to a resource for creating the action, that'll work too.

 

Thanks in advance 😉

This topic has been closed for replies.

2 replies

Thom Parker
Community Expert
Community Expert
February 26, 2020

If you downloaded that Action from the Actions Exchange at AcrobatUser.com, then I wrote it. The entire action is written in JavaScript, and Lori is not a programmer. 

To get a word count you can simply multiply the number of highlight annotations by the number of words in the search. 

 

Another approach would be to modify this action to keep a running count of the words found.  However, Extracting the script is a bit of a trick. It was writtin for Acrobat X, and will not open in the Actions' editor in Acrobat DC. However, you can get to the script by editing the XML. 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
EX-1Author
Participant
February 26, 2020

Thom,

 

Thanks very much for the insight.  Any thoughts on an efficient way to obtain a count of the first occurrence of each highlight?

try67
Community Expert
Community Expert
February 26, 2020

Do you want to count the number of occurrences or do you want to know which search terms had a match? Either way, you would need to use a custom-made script to do it.

try67
Community Expert
Community Expert
February 25, 2020

If the highlights contain the search term as their contents then you could do it with a script that loops over all the comments (annotations) in the file and checks their type and contents properties for unique values.