Skip to main content
Participant
April 29, 2025
Question

Appending Symbols and different fonts in a single Rich Text field

  • April 29, 2025
  • 1 reply
  • 329 views

Hello,

I'm new to all this but i'm trying to display user entered data in a ceratin format but in 1 RichText field.

I have a text Field (Field1) which you can enter a price eg 1.99

But i want to be able to display this in Field3 (RichText) but depending on Field 2 it would add £ or p.
So Field2 Contains '£' Vaule pound and 'p' value pence.

 

If pound it would be at front and if pence at end.
However i need the Field3 to display the above in different font Sizes. The symbol would be 1 size and price a different, but linked in Field 3 so it can be centered no matter what price is entered.

Really hope that makes sense. Sorry not the best at wording things.

Any help or pointers would be great, i', not even sure if it can be done.

Please see attached example of required out come

1 reply

Thom Parker
Community Expert
Community Expert
April 29, 2025

Rich text can get as complex as you want. A "Rich Text" string is divided into a series of "Spans", where each span is a defined set of font characteristics. So, divide up your text into the number or individual spans that are needed to display the text in the required format. 

 

Here's the JS reference for the "Span" object:

https://opensource.adobe.com/dc-acrobat-sdk-docs/library/jsapiref/JS_API_AcroJS.html#span

 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Participant
April 29, 2025

Hi,

Thank you for your reply. Do you know how i'd go about making the text to top of the field? I can't find anything about v-alignment?

Regards

 

Martin

Thom Parker
Community Expert
Community Expert
April 29, 2025

There are several missing and undocumented parameters.  By missing I mean that some of the parameters that can be set from the UI, don't have a span property. 

So first, the field must be multiline for vertical alignment to have meaning. The natural alignment is to the top. 

If you have a multiline, rich text field, then do this

1.  Enter some multiline text.

2. Open the properties dialog (Ctrl-e)

3. Selec More...

4. Select the paragraph tab.

5. You'll see a vertical alignment property.  Set it to align on the bottom. 

6. Open the Console Window (Ctrl-J)

7. Enter and run this code. 

    this.getField("Your Field Name").richValue.toSource();

 

All the span properties will be displayed. There will not be one for the vertical alignment, even though you can set it from the UI. 

 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often