These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Amount in figures to words

nalakahe
Registered: Jul 17 2011
Posts: 11
Answered

I am using acrobat pro x - form and i need a script to convert numbers, automatically to words.
Eg.2,500.55---> Two Thousand Five Hundred and Cents Fifty Five
Regards
Nalaka

NalakaHE

My Product Information:
Acrobat Pro 7.0, Windows
try67
Expert
Registered: Oct 30 2008
Posts: 2398
Have a look at these threads:
http://acrobatusers.com/forum/javascript/script-convert-numeric-percentage-text
http://acrobatusers.com/forum/forms-acrobat/convert-number-word

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

nalakahe
Registered: Jul 17 2011
Posts: 11
I used following script at Custom calculation script.
var f = this.getField("Number");event.value = ConvertToWords(f.value);
But i am getting unbeleivable answer.
When i insert 25,769.65---->Twenty-Five Thousand Dollars and Sixty-Five Cents is the output.It's not generating the correct word phrase the entered amount.

Also, currency code automatically decided by the system too. I need the words line in common
Thanks
Nalaka

NalakaHE

nalakahe
Registered: Jul 17 2011
Posts: 11
I used following script at Custom calculation script.
var f = this.getField("Number");event.value = ConvertToWords(f.value);
But i am getting unbeleivable answer.
When i insert 25,769.65---->Twenty-Five Thousand Dollars and Sixty-Five Cents is the output.It's not generating the correct word phrase the entered amount.

Also, currency code automatically decided by the system too. I need the words line in common
Thanks
Nalaka

NalakaHE

gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
Accepted Answer
Are getting any errors in the Acrobat JavaScirpt console?

Did you copy the entire script?

The code for that script comes from the Check.PDF sample form provided with the full version of Acrobat:

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;
}

There is no sure way to automatically adjust the currency words since you can not access the format of the numeric field, you will need to edit the function to match the currency used in the input form field.

George Kaiser

nalakahe
Registered: Jul 17 2011
Posts: 11
I copied entire scripts on "Format" tab, under "customs keysroke scripts" cage.
But it's not working yet

NalakaHE

gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
In the Adobe provided example, the function was Entering Document Level Scripts and then the text field for the number as words is filled in with the Custom JavaScript calculation:var f = this.getField("Number");
event.value = ConvertToWords(f.value);

Example Check Form is a working copy of a check form.

George Kaiser