How to apply javascript to specific areas of a pdf via bookmarks
This is really a "part 2" leading on from an earlier post Solved: Re: Cumulative word count... - Adobe Support Community - 11669143
Having been given an elegant piece of code by @try67 to paste a cumulative word count at the bottom of every page -
var r = [5, 25, 50, 5];
var counter = 0;
for (var p=0; p<this.numPages; p++) {
var numWords = this.getPageNumWords(p);
counter+=numWords;
//console.println("Number of (total) words on page " + (p+1) + ": " + counter);
var f = this.addField("PageText"+p, "text", p, r);
f.readonly = true;
f.defaultValue = counter;
f.value = counter;
}
This works perfectly for the document as a whole. What I'm hoping to achieve next is to apply that same script to separate "chapters" within a pdf.
Chapters are defined by a bookmark at the start of each chapter, so the script needs to start the cumulative count at the first bookmark, up to the second, then start again from the second.. and so on.
Am looking for any suggestions as to how this can be achived via javascript?
