Skip to main content
Participant
February 24, 2020
Question

Count highlighted words and phrases

  • February 24, 2020
  • 2 replies
  • 3551 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?

EX-1Author
Participant
February 28, 2020

To create a solution you need to either 

1) find something unique about the highlights that a script can detect, so they can be counted,

You can obtains a list of all annotations on the PDF with 

var aAnnots = this.getAnnots();

 

This list can then be filtered for specific characteristics, which will give you the count. 

The trick is determining the criteria for filtering.

 

2) modify the existing script to add in the counting feature you want. 

 

I would be happy to do this for a fee.  Contact me through www.windjack.com

 

 


Thom,

 

That's really helpful!  Let me give that try and I'll get back to you.

Many thanks for your time and insight.

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.