How to Count total number of Words in PDF?

Is there a javascript (or some other) function i can use to count the number of words on a web page?

  • I don't want to count the words in a text box. I want to pass an http reference and return the number of words on the page.

  • Answer:

    I can't think of an easy way to do it using javascript, but if you can use a server side script it shouldn't be too difficult. In PHP it would be: $string = "a lot of text, the content of your page or whatever"; $string = striptags( $string );//remove any html tags that would throw this off $string = preg_replace("/\w+/", " ", $string);//change all white space characters, or groups of white space to one space $string = trim($string);//remove any leading or trailing white space $array = explode(" ",$string);//change the string to an array broken on spaces $wordCount = count($array);

jack b at Yahoo! Answers Visit the source

Was this solution helpful to you?

Other answers

nope, you would have to use the innerText property and analise the string yourself, maybe use the split function to count words

Deep Thought

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.