Copy link to clipboard
Copied
How do I get a word count for a PDF doc or for a selected passage?
Copy link to clipboard
Copied
You need to create a custom Keystroke script, as that's the only one that is executed each time you type something into the field.
If you're interested I've already developed a tool that does just that: Custom-made Adobe Scripts: Acrobat -- "Live" Characters and Words Counter
Copy link to clipboard
Copied
You'll find scripts for counting words, letters, etc. here:
Calculating field values and more
As Try says, you'll need to use a custom keystroke event. This is tricky because event.value does not include the newly typed text, so you'll need to combine both event.value and event.change.
Here's how:
if(!event.willCommit)
{
var nChars = event.selEnd - event.selStart;
var aFull = event.value.split("");
aFull.splice(event.selStart, nChars, event.change);
var strFull = aFull.join("");
var aWrds = strFull.split(/\s+/);
... rest of code ...
}
Using the regEx for the split catches multiple spaces, tabs, and line feeds
Copy link to clipboard
Copied
"Word counter" is one of my free plugins for Acrobat:
https://www.abracadabrapdf.net/utilitaires/utilities-in-english/abracadabratools_en/