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

Formatting only part of the output of a field in a PDF form.

Explorer ,
May 24, 2020 May 24, 2020

Copy link to clipboard

Copied

I am concatinating two fields with a text string using the following as a custom calculation:

event.value = "Words" + this.getField("D1").valueAsString + this.getField("F1").valueAsString;

 

Field F1 is actually a numeric value.    I would like to chnge the fomrattign of how F1 appears for readinility.  Something as simple as making it bold would be enough, but also increasing the font size would be good as well.

I do not want to change the formatting of "Words" or D1 so I don't think I can do with global formatting.

Is it possible because F1 is a number I could use soem conditional statment to bold only numbers in event.value?

TOPICS
Acrobat SDK and JavaScript

Views

514

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

correct answers 1 Correct answer

Community Expert , May 26, 2020 May 26, 2020

Don't forget to mark this solution as correct answer.

Votes

Translate

Translate
Explorer ,
May 25, 2020 May 25, 2020

Copy link to clipboard

Copied

Problem Solved by rjunke

 

Here is the solution provided that worked

 

"Try something like this:

Place the conditional script in the number field and have it output to the text field. You'll need to use an array() to get the conditional formatting you want.

I created a number field formatted as a number and created a text field with no formatting. In the number field I added this custom calculation script:

var v = this.getField("Number1").valueAsString;

var spans = new Array();

spans[0] = new Object();
spans[0].text = "Words: ";
spans[0].fontWeight = 400; // normal weight

spans[1] = new Object();
spans[1].text = v; // insert the value we read from the field
spans[1].fontWeight = 800; // bold

var f = this.getField("Text16");
f.richText = true; // make sure we are dealing with a rich text field
f.richValue = spans;

 

The array gets written to the text field as richtext.

 

Hope this helps."

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
Community Expert ,
May 26, 2020 May 26, 2020

Copy link to clipboard

Copied

LATEST

Don't forget to mark this solution as correct answer.

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