3 Replies Latest reply on Aug 6, 2014 1:02 PM by felisaleonard3

    Acrobat X number to word

    felisaleonard3 Level 1

      Is there a function that I can use in the Acrobat X form under custom script to convert a number that is entered in a field to words, like 2014  would become Two thousand and fourteen...the function would be similar to the FormCalc funct Numword() the only reason I can't use LiveCycle the document was scanned and I converted it to a form from Adobe X....I tried to open it in LiveCycle but I do not get the image of the form...any help will be greatly appreciated

        • 1. Re: Acrobat X number to word
          gkaiseril MVP & Adobe Community Professional

          Yes, in fact a function to perform this task is included on the distribution disk for Acrobat as a sample form since Acrobat 4.

           

          aTens = [ "Twenty", "Thirty", "Forty", "Fifty", "Sixty", "Seventy", "Eighty", "Ninety"];
          aOnes = [ "Zero", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine",
            "Ten", "Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen",
            "Nineteen" ];

          function ConvertToHundreds(num)
          {
             var cNum, nNum;
             var cWords = "";

             num %= 1000;
             if (num > 99) {
                /* Hundreds. */
                cNum = String(num);
                nNum = Number(cNum.charAt(0));
                cWords += aOnes[nNum] + " Hundred";
                num %= 100;
                if (num > 0)
                   cWords += " and "
             }

             if (num > 19) {
                /* Tens. */
                cNum = String(num);
                nNum = Number(cNum.charAt(0));
                cWords += aTens[nNum - 2];
                num %= 10;
                if (num > 0)
                   cWords += "-";
             }

             if (num > 0) {
                /* Ones and teens. */
                nNum = Math.floor(num);
                cWords += aOnes[nNum];
             }

             return cWords;
          }

          function ConvertToWords(num)
          {
             var aUnits = [ "Thousand", "Million", "Billion", "Trillion", "Quadrillion" ];
             var cWords = (num >= 1 && num < 2) ? "Dollar and " : "Dollars and ";
             var nLeft = Math.floor(num);
             for (var i = 0; nLeft > 0; i++) {
                 if (nLeft % 1000 > 0) {
                    if (i != 0)
                       cWords = ConvertToHundreds(nLeft) + " " + aUnits[i - 1] + " " + cWords;
                    else
                       cWords = ConvertToHundreds(nLeft) + " " + cWords;
                 }
                 nLeft = Math.floor(nLeft / 1000);
             }
             num = Math.round(num * 100) % 100;
             if (num > 0)
                cWords += ConvertToHundreds(num) + " Cents";
             else
                cWords += "Zero Cents";

             return cWords;
          }

          • 2. Re: Acrobat X number to word
            felisaleonard3 Level 1

            Thank you...

            • 3. Re: Acrobat X number to word
              felisaleonard3 Level 1

              I am new to the javascripting part of Acrobat...do I place all the above info in the custom scripting for the format of the field?  I'm not sure what I'm doing wrong....I tried it also in LiveCycle and I get is the number as well