4 Replies Latest reply on Jun 9, 2008 11:03 AM by Patrick Leckey

    character count

      I would like to ask whether it is possible to count characters in pdf by means of javascript?
      I know it is possible to count words for each page and add them together (getPageNumWords()) but I cannot find anything similar for characters.

      Thanks for any hint in advance.
        • 1. Re: character count
          Patrick Leckey Level 3
          You would have to get each word, and then in JavaScript you can use the "length" property of String objects to get the number of characters in that word. Like this:

          var myString = "This is a string!";
          var myStringLength = myString.length;
          // Will output 17
          console.println("String Length: " + myStringLength);
          • 2. Re: character count
            gkaiseril MVP & Adobe Community Professional
            Yes, you need to write some custom JavaScript to sum the length of each word on each page and the total of each page's length of words to the doucment total. The number of characters would be same as the the length of the word string.

            You might want to consider writing 2 functions, one to sum the characters on a page, and one to use the character sum for the page to sum the number of characters for the document. One could then add custom menu items to count the characters on the current page and the current document.
            • 3. Re: character count
              Level 1
              thank you very much. I'm into it.
              I'll publish the javascript once I finish it.
              I'm not very experienced about adobe dev community, so I would like to ask where should I publish it (under gpl) for people to find it easily?
              Is there any centralized place for such things?
              • 4. Re: character count
                Patrick Leckey Level 3
                > Is there any centralized place for such things?

                Not really. Perhaps petition for a new category to be added to freshmeat.net, or just add it to SourceForge if you really want to publish it.