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

Javascript: insert text into textbox with 2 formats

Participant ,
Mar 06, 2023 Mar 06, 2023

Hey thanks for reading. 

 

I need a textbox with two formatting types. Basically, I will insert 1 string as a title and another as a body.

For example, it should say "Acceptance of Offer: " in one font (Avenir-Black), and then "To indicate your acceptance..." in another font (Avenir-Light).

TOPICS
JavaScript , PDF forms
469
Translate
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 ,
Mar 06, 2023 Mar 06, 2023
LATEST

You'll need to use the "Rich Text" option for the field, and then set the rich field value to a spans object.

The best way to figure out the "spans" you need is to do this process manually, i.e. type text into the field (that's to be set to rich text), and then use the text properties bar (Ctrl-E) to set the font properties.  

Then use the console window to see how the spans are set.

For example:

this.getField("the rich field").richValue.toSource();

 

 

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

Translate
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