javascriptacrobatword-countadobe-javascript

Adobe Script to show active Word Count


I have a script that allows me to view the Character Count limit, and then it counts down. I would prefer to display a Word Count instead because the majority of people don't count characters. I've attached a link to the pdf I've created for that.

http://webfro.gs/south/Adobe/Character%20Countdown.pdf

In Properties > Actions > On Focus > Run a Javascript - I have the following script running...

var maxlim=event.target.charLimit; if (event.target.value.length==0) this.getField("cntdwn").value=maxlim;

Then, in Properties > Format > Custom Keystroke Script - I am running this Countdown script

var value = custmMergeChange(event); var L = value.length; this.getField("cntdwn").value=(maxlim-L);

Is there something out there that can display a Word Count and when the word count is reached (counting up) or it reaches zero (counting down), can the ability to type any further be stopped?

How's this possible?


Solution

  • In answer to the comment:

    Not a preset variable per se, but there is an answer here, that should help.

    Try this, then. It's directely from the Adobe forums, and answers your question more directly.

     for (var i = 0; i < input.length; i++) {
            var ch = input.charAt(i);
            var str = new String("" + ch);
    
            if (i+1 != input.length && str === " " && "" + input.charAt(i+1) !== " "){
                wordCount++;
            }