Skip to main content
New Participant
December 5, 2012
Question

Word Count

  • December 5, 2012
  • 10 replies
  • 236422 views

How do I count words in an English PDF document?

10 replies

New Participant
August 10, 2024
  1.  
New Participant
September 2, 2023

sumon gazi

ls_rbls
Brainiac
January 26, 2020

Hi,

 

++Adding to this old thread, here's an workaround observation that turned out to work for me in both Acrobat Reader DC and partially in Adobe Reader mobile app, and a third party mobile PDF viewer.

 

Adobe Acrobat Reader mobile app doesn't have word count and neither does Acrobat Reader DC.

 

However, the following method proved to be useful:

 

  • with Acrobat Pro DC you can create a single blank PDF page, and place a button with a javascript action to perform a word count. 

 

  • Download the PDF with the button script to your mobile device via USB cable, or get the PDF with the action button from here: Word Count Action Script Button  

 

  • And all you have to do is open Acrobat Reader Mobile and merge or combine this PDF with whatever document you want to perform the word count with. You can do the same with Adobe Reader DC 

 

 

See slides below.

 

With your main document opened select combine files and add the PDF with the button script that I've shared above

 

 

 

Select Combine to merge both PDFs.

 

 

 

 

  • When you open your combined PDF file click on the action script button to get the wordcount of your merged PDF document. 

 

Below, selecting Organize Pages tool to see the final result of the merged documents :

 

 

NOTE: Be advised that the wordcount script might not be entirely accurate since the total word count seems to vary from app to app.

 

For example, in Adobe Reader DC the script will count all of the form field objects (like  text form fields, drop down menus, and even the event button objects with a label) even if they're blank, and then include in the word count total all of these form field object plus the real count of the text words that were found throughout the PDF.

 

Curiously enough, in a third-party appp like Foxit,  it is able to count the exact words that are in the PDF.

 

For some reason I haven't been able to have the script  to work in Adobe Reader mobile app, but the Adobe Reader app does allow me to merge two or more documents with the PDF that has the script.

 

On the other hand, the third party mobile app doesn't provides me with a merging capability (that I know of) but the script executed and worked fine in this third party app after it was merged with the Adobe Adobe Reader mobile app.

 

Here is the script originally posted by Dave Merchant: 

 

 

 

 

 

 

var cnt=0;

for (var p = 0; p < this.numPages; p++) cnt += getPageNumWords(p);

app.alert("There are " + cnt + " words in this file.");

 

 

 

See slide below using third party app:

 

 

 

 

 

 

 

 

 

 

try67
Brainiac
January 26, 2020

This won't work in Reader DC, since it can't merge PDF files.

ls_rbls
Brainiac
January 26, 2020

Correct, but with the Reader mobile app (at least with AndroidOS) allows to merge using the Organize Pages tool.

 

The user will need a paid subscription with Acrobat Pro DC of course.

 

Then upload the PDF back to the cloud back to a PC with Reader.

 

I know... is completely unorthodox, but just food for thought for those great developers out there such as yourself.

SEOToolsCentre_s_Team
New Participant
May 22, 2017

Hi Dynamedix,

There are many software or online word counter tools are available on the Google to count the words. It's the really the very tough task if you count one by one. To count the word with in the PDF file

  • Just select all the content.
  • Copy and paste it into the word document.
  • Go to formatting section and hit the word count option and the total number of the words will be displayed.

Otherwise try other online word count tool by uploading file or extracting the text.

ShylieWoods
New Participant
February 21, 2017

Love this - but anyone know how to tweak the JS to count a specific page/page range? Thanks

try67
Brainiac
February 21, 2017

Let's say you want to count from page 3 to page 10.

Change this part of the code:

for (var p = 0; p < this.numPages; p++)

To this:

for (var p = 2; p<=9; p++)

(notice the page numbers are 0-based...)

ShylieWoods
New Participant
February 21, 2017

Awesome! Thanks so much for the super speedy reply  

Stauersboell
New Participant
November 10, 2016

I have used the below JavaScript, and it works well. But does anyone know, if it is possible to make a JavaScript that instead of counting words, counts characters including spaces?

var cnt=0;

for (var p = 0; p < this.numPages; p++) cnt += getPageNumWords(p);

console.println("There are " + cnt + " words in this file.");

Brainiac
November 10, 2016

You could write a script that looped through the words, got the number of characters in each one, and added together. You can't get spaces or punctuation, the spaces often aren't even there (just gaps). You could add 1 for each word, which would be approximate but not (for example) a solid basis for payment.

try67
Brainiac
November 10, 2016

Actually, you can get spaces and punctuation by setting the third parameter (bStrip) of getPageNthWord as false.

This code will count all the characters in a document:

var charCount = 0;

for (var p=0; p<this.numPages; p++) {

    var numWords = this.getPageNumWords(p);

    for (var i=0; i<numWords; i++) {

        var word = this.getPageNthWord(p,i,false);

        charCount+=word.length;

    }

}

app.alert("There are " + charCount + " characters in this file.",3);

alearn3
New Participant
February 16, 2016

On Windows platform you can use AnyCount Word Count and Character Count Software

It supports word count in 38 formats including PDF. Actually, it can count even on PC without Adobe Acrobat installed.

Participating Frequently
October 20, 2013

You can also create an Action Wizard with Dave's script and by changing "console.printIn" to "app.alert" a dialog box will pop up with the page count.

try67
Brainiac
October 20, 2013

Actions are not available in Reader, only in Acrobat Pro.

And using an alert in an Action is counter-productive as it means you have to sit in front of it, clicking OK, OK, OK...

It's better to print out the result to the console, preceded by the name of the file that's being processed.

Then when the process is done you open the console and see all the results in one glance.

~graffiti
Brainiac
December 5, 2012

Or, you could copy/paste into a Word document and do the word count there.

Brainiac
December 5, 2012

There's no built-in word count tool. In Adobe Acrobat you can use a console JavaScript:

var cnt=0;

for (var p = 0; p < this.numPages; p++) cnt += getPageNumWords(p);

console.println("There are " + cnt + " words in this file.");

Participating Frequently
November 18, 2013

When i use the script :

var cnt=0;

for (var p = 0; p < this.numPages; p++) cnt += getPageNumWords(p);

app.alert("There are " + cnt + " words in this file.");

I keep getting word count 0 on all PDFs?

Any ideas?

Participating Frequently
November 19, 2013

The document is probably scanned and was not OCR-ed, so it doesn't contain

any actual words in it, just images with text on them...


The PDF is full text, when i copy and paste to word the count is 1,052 words - Im just wondering whether i need to edit the script at all?

Script i am using -

var cnt=0;

for (var p = 0; p < this.numPages; p++) cnt += getPageNumWords(p);

app.alert("There are " + cnt + " words in this file.");