Many times I wanted to count the number of words in a PDF document. The normal way to do this task is to save the file as a Word doc and then open it in MS Word that calculates the count. You can also upload your file to an online site that will count it (although most companies would probably frown upon sending your precious data to some random 3rd party site).
Today I stumbled across an Adobe forum thread that said that Acrobat can run JavaScript. Hmmm... And then I found another site that explains how to create a custom tool in Acrobat. Put these two together and you get a toolbar button in Adobe Acrobat to count the number of words in the doc.
Here's how to make it work. Note that this is for Acrobat DC.
- Open Acrobat.
- Click Tools.
- Click Action Wizard.
- In the button list under the toolbar, click New Custom Command.
This window opens:
- Click Execute JavaScript.
- Change the Label to something useful, like "Count words in document".
- Change the Tool tip to something useful, like "Counts the number of words in the current document".
- Click Command Options...
- Paste in the following code:
/* Count number of words in document */
var cnt = 0;
for (var p = 0; p < this.numPages; p++) cnt += getPageNumWords(p);
app.alert("There are " + cnt + " words in this file.");
- Click OK.
- Click Don't show options, options are always the same.
- Click OK.
- Right-click in a blank part of the toolbar.
- Click Customize Quick Tools.
- Expand the Action Wizard section.
- Find your new command and select it.
- Click the Add to Toolbar button on the right side of the window.
- Click Save.