• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Combining formatting scripts in Javascript for Adobe PDF forms

New Here ,
Sep 25, 2024 Sep 25, 2024

Copy link to clipboard

Copied

Hello,

 

I am relatively new to Javascript in general and I am having trouble finding a solution to my current issue. I have two pieces of code which I have found on this forum previously that I need to be set to the formatting script of a field that is created in my code. these are as follows:

 

Code 1:

f.setAction("Format", "event.value = util.printf(\"£%,0.2f\",event.value);");

 

Code 2:

event.richText = true;
var spans = new Array();
spans[0] = new Object();
spans[0].text = event.value;
spans[0].strikethrough = true;
event.richValue = spans;

 

I need to find a way to combine them together so that they both function. The idea is that I can assign a value to a field that is 500 for example, and it will display as £500.00 with a strikethrough.

 

Any help is very appreciated.

TOPICS
How to , JavaScript , PDF , PDF forms

Views

116

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 25, 2024 Sep 25, 2024

Copy link to clipboard

Copied

Where is the setAction Format code triggered?  Why not just manually format the field that way in the format tab?  To set the richText property to true with a script in the field, use event.target.richText=true NOT event.richText=true.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 27, 2024 Sep 27, 2024

Copy link to clipboard

Copied

LATEST

The reason that I cant manually format the field in the format tab is because the field itself is created earlier within the code. So the field doesn't exist for me to format until the user selects the relevant options etc. which will create the field. Thanks for the info on event.target.richText, I will update my current code.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines