6 Replies Latest reply on Mar 4, 2013 1:34 AM by Test Screen Name

    How do i convert numeric values into english words for Custom formatting adobe forms?

    HARISH_JANGIR

      How do i convert numeric values into english words I want a script

      for custom formatting.

      like  1,50,655.00 = ONE Lac fifty thousand six hundred fifty five only

      if num. in desimal 1,50,655.50  = ONE Lac fifty thousand six hundred fifty five & fifty cent only

       

       

      plz help me.

       

       

      thanks

      Harish

        • 1. Re: How do i convert numeric values into english words for Custom formatting adobe forms?
          gkaiseril MVP & Adobe Community Professional

          This takes a rather sizable amount of code and the example provided by Adobe will have to modified to meet your needs.

           

          With the full distribution DVD/CD for Acrobat there is sample form for a a check that has the following function:

           

          function ConvertToHundreds(num)
          {
          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" ];
           
             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 = "and ";
             // var cWords = (num >= 1 && num < 2) ? "Dollar and " : "Dollars and "; // use for spelled out words
             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;
               cWords += util.printf("%,102.0f/100 Dollars", num); // numerical cents
             /* for spelled out cents
             if (num > 0) {
                 cWords += ConvertToHundreds(num) + " Cents"; // spelled out cents
             } else {
                 cWords += "Zero Cents";
              }
          */
             return cWords;
          }


          The above function is located as a document level script and in the field for the worded amount the following custom calculation script is used to convert the value of the field named "Number".

           

          var f = this.getField("Number");

          event.value = ConvertToWords(f.value);

          • 2. Re: How do i convert numeric values into english words for Custom formatting adobe forms?
            HARISH_JANGIR Level 1

            thanks

            but its Show 100,000 = hundred thousand doller and zero cent

            i want          100,000 = One Lac doller and zero cent

             

            I unble to edit this script .So please anybody can edit this script for me.

             

            thanks

            Harish

            • 3. Re: How do i convert numeric values into english words for Custom formatting adobe forms?
              try67 MVP & Adobe Community Professional

              Just go over the code and wherever is says "Dollars" replace it with "Lac Dollars"... It's not that complicated.

              • 4. Re: How do i convert numeric values into english words for Custom formatting adobe forms?
                HARISH_JANGIR Level 1

                1                                 one doller

                100                             One hundred 

                1,000                           One thousand

                1,00,000                       One Lac

                10,00,000                     Ten lac

                 

                This is not a currency name.

                 


                • 5. Re: How do i convert numeric values into english words for Custom formatting adobe forms?
                  Test Screen Name Most Valuable Participant

                  It's an interesting programming problem. Are you really asking us to do your job for you?

                  • 6. Re: How do i convert numeric values into english words for Custom formatting adobe forms?
                    Test Screen Name Most Valuable Participant

                    By the way, for confused readers: Lak (often spelled lakh) and crore are often used as multipliers for numbers in spoken or written English but are almost unknown outside the Indian subcontinent. Lak = hundred thousand (10^5) and Crore = hundred million (10^10). So the population of Calcutta (Kolkata), about five million, is likely to written as fifty lakh and the population of Bombay/Mumbai is about two crore.

                     

                    Even more confusing, because it looks like an error to people only used to the arabic system is the tendency to group numbers into pairs with commas (except the last three):

                     

                    Arabic: 121,212,123

                    Indian: 12,12,12,123

                     

                    More information: http://en.wikipedia.org/wiki/South_Asian_numbering_system

                     

                    Non Indian readers may find it useful to be aware of these, and essential if they want to deal with the Indian subcontinent.

                    Indian subcontinent readers may find it useful to know that these are simply unknown in much of the English speaking world.