Skip to main content
DavidSweeneyBear
Inspiring
February 22, 2020
Answered

Words per PAGE javascript

  • February 22, 2020
  • 4 replies
  • 2270 views

Hi, I'm looking for a way to calculate how may words are on each page of a pdf rather than the whole document.

Does anyone know if getPageNumWords could be used to do this?

The query would need to recognize the position of the cursor in order to define the "current page" - is that possible?

Many thanks.

This topic has been closed for replies.
Correct answer try67

Use this:

 

var numWords = this.getPageNumWords(this.pageNum);
app.alert("There are " + numWords + " words in this page.", 3);

4 replies

JR Boulay
Community Expert
Community Expert
February 23, 2020

My free abracadabraTools adds a Word Counter item in Acrobat's Edit menu:

https://www.abracadabrapdf.net/utilitaires/utilities-in-english/abracadabratools_en/

 

Acrobate du PDF, InDesigner et Photoshopographe
DavidSweeneyBear
Inspiring
February 23, 2020

sorry, but the document word count returns "0" and the page word count does nothing.

<br>~ David Sweeney-Bear ~
DavidSweeneyBear
Inspiring
February 23, 2020

This does the job in console.... I'm just wondering how I might get it to output to a popup window, something like:

app.alert("There are " x " words in this page.");

Sorry - I really don't understand Javascript at all!

<br>~ David Sweeney-Bear ~
try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
February 23, 2020

Use this:

 

var numWords = this.getPageNumWords(this.pageNum);
app.alert("There are " + numWords + " words in this page.", 3);

DavidSweeneyBear
Inspiring
February 23, 2020

thanks so much... works like a charm 🙂

<br>~ David Sweeney-Bear ~
try67
Community Expert
Community Expert
February 22, 2020

That's exactly what this function does. Use this code to retrieve the number of words in the current page (the one being viewed, not necessarily where the cursor is located):

this.getPageNumWords(this.pageNum)

DavidSweeneyBear
Inspiring
February 23, 2020

Brilliant, thanks a mill!

<br>~ David Sweeney-Bear ~
DavidSweeneyBear
Inspiring
February 22, 2020

... or if not the position of the cursor then some other way of recognizing the individual page to do the calculation for.

<br>~ David Sweeney-Bear ~