Count the Number of Words using JavaScript in Adobe Acrobat

This is the best hack that I’ve come across in the last several years.

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.

  1. Open Acrobat.
  2. Click Tools.
  3. Click Action Wizard.
  4. In the button list under the toolbar, click New Custom Command.
    This window opens:

  5. Click Execute JavaScript.
  6. Change the Label to something useful, like “Count words in document”.
  7. Change the Tool tip to something useful, like “Counts the number of words in the current document”.
  8. Click Command Options…
  9. 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.");
  10. Click OK.
  11. Click Don’t show options, options are always the same.
  12. Click OK.

You now have a custom command. All that’s left to do is make the button that calls it.

  1. Right-click in a blank part of the toolbar.
  2. Click Customize Quick Tools.
  3. Expand the Action Wizard section.
  4. Find your new command and select it.
  5. Click the Add to Toolbar button on the right side of the window.
  6. Click Save.

That’s it! You can now open any PDF and just click the button to get a word count.

[Source: KHKonsulting and Adobe]

    What is a Lexophile?

    1. lexophile – A lover of cryptic words

    For those of you who like punny lists:

    1. A bicycle can’t stand alone; it is two tired.
    2. A will is a dead giveaway.
    3. Time flies like an arrow; fruit flies like a banana.
    4. A backward poet writes inverse.
    5. In a democracy it’s your vote that counts; in feudalism, it’s your Count that votes.
    6. A chicken crossing the road: poultry in motion.
    7. If you don’t pay your exorcist you can get repossessed.
    8. With her marriage she got a new name and a dress.
    9. Show me a piano falling down a mine shaft and I’ll show you A-flat miner.
    10. When a clock is hungry it goes back four seconds.

    11. The guy who fell onto an upholstery machine was fully recovered.
    12. A grenade fell onto a kitchen floor in France resulted in Linoleum Blownapart.
    13. You are stuck with your debt if you can’t budge it.
    14. Local Area Network in Australia : The LAN down under.
    15. He broke into song because he couldn’t find the key.
    16. A calendar’s days are numbered.
    17. A lot of money is tainted: ‘Taint yours, and ‘taint mine.
    18. A boiled egg is hard to beat.
    19. He had a photographic memory which was never developed.
    20. A plateau is a high form of flattery.
    21. The short fortuneteller who escaped from prison: a small medium at large.
    22. Those who get too big for their britches will be exposed in the end.
    23. When you’ve seen one shopping center you’ve seen a mall.
    24. If you jump off a Paris bridge, you are in Seine.
    25. When she saw her first strands of gray hair, she thought she’d dye.
    26. Bakers trade bread recipes on a knead to know basis.
    27. Santa’s helpers are subordinate clauses.
    28. Acupuncture: a jab well done.
    29. Marathon runners with bad shoes suffer the agony of de feet.
    30. The roundest knight at king Arthur’s round table was Sir Cumference. He acquired his size from too much pi.
    31. I thought I saw an eye doctor on an Alaskan island, but it turned out to be an optical Aleutian.
    32. She was only a whisky maker, but he loved her still.
    33. A rubber band pistol was confiscated from algebra class because it was a weapon of math disruption.
    34. The butcher backed into the meat grinder and got a little behind in his work.
    35. No matter how much you push the envelope, it’ll still be stationery.
    36. A dog gave birth to puppies near the road and was cited for littering.
    37. Two silk worms had a race. They ended up in a tie.
    38. A hole has been found in the nudist camp wall. The police are looking into it.
    39. Atheism is a non-prophet organization.
    40. Two hats were hanging on a hat rack in the hallway. One hat said to the other, ‘You stay here, I’ll go on a head.’
    41. I wondered why the baseball kept getting bigger. Then it hit me.
    42. A sign on the lawn at a drug rehab center said: ‘Keep off the Grass.’
    43. A small boy swallowed some coins and was taken to a hospital. When his grandmother telephoned to ask how he was, a nurse said, ‘No change yet.’
    44. The soldier who survived mustard gas and pepper spray is now a seasoned veteran.
    45. When cannibals ate a missionary, they got a taste of religion.
    46. Don’t join dangerous cults: Practice safe sects.