Skip to main content
Participating Frequently
November 10, 2019
Answered

PDF Forms JS: Extract formatted number field as displayed into a string

  • November 10, 2019
  • 2 replies
  • 3196 views

Hello,

 

Everything is in the object.

I've developed a relatively complex pdf form with JS customization.

 

I would like to insert in a text field a string that would contain a formatted number field as it is displayed.

 

Example: the numerical value is 25.1 is displayed in the field as 25,10 USD***, (the formatting changes depending on user's choices in other fields, for example the same value might be displayed as 25,100 TND*** ...) 

I wish to extract the string "25,10 USD***" not the 25.1.

I tried using the formattedValue/editValue/rawValue properties but none of those worked.

 

Is it possible to do what I want? If so, how can I do it?

 

Thanks

This topic has been closed for replies.
Correct answer Thom Parker

Formatting in Acrobat forms is done with JavaScript.

Try the "util.printx()"function.

https://help.adobe.com/en_US/acrobat/acrobat_dc_sdk/2015/HTMLHelp/#t=Acro12_MasterBook%2FJS_API_AcroJS%2Futil_methods.htm%23TOC_printxbc-5&rhtocid=_6_1_8_78_0_4

 

But the better function is "util.printf()"

2 replies

Legend
November 10, 2019

I found those three values discussed here https://blogs.adobe.com/formfeed/2011/06/understanding-field-values.html in the context of XFA (LiveCycle Designer) forms - though the blog post at no point mentions that! That will do no good for Acrobat forms.

Zetto1976Author
Participating Frequently
November 10, 2019

Ok, it's clear thanks.

 

Is there any equivalent in Adobe forms?

Thom Parker
Community Expert
Thom ParkerCommunity ExpertCorrect answer
Community Expert
November 11, 2019

Formatting in Acrobat forms is done with JavaScript.

Try the "util.printx()"function.

https://help.adobe.com/en_US/acrobat/acrobat_dc_sdk/2015/HTMLHelp/#t=Acro12_MasterBook%2FJS_API_AcroJS%2Futil_methods.htm%23TOC_printxbc-5&rhtocid=_6_1_8_78_0_4

 

But the better function is "util.printf()"

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Bernd Alheit
Community Expert
Community Expert
November 10, 2019

You must format the value.

Zetto1976Author
Participating Frequently
November 10, 2019

Hello,

 

How can I achieve it?

I was able to format the number field (separator style, decimals, currency suffixe...) and display it correctly, but can't get the result in a string so I can use it in another text field.

 

Thanks

Bernd Alheit
Community Expert
Community Expert
November 10, 2019

You can use util.printf for this.