How to bold text in JavaScript

Feb 13, 2020

Copy link to clipboard

Copied

I have the following code which is just draft at the moment as I build it up, but I want to bold the text when the checkbox value is on:

 

if(event.target.value=="Off"){ this.getField("Text11").value = "Hmmm"; } else { this.getField("Text11").value = "WORK"; }

 

So, in this instance when the box is ticked I want the 'Text11' field to display 'WORK' which it is doing, but I want that text to be bold.

 

Can someone help me with the code for doing this?

TOPICS
Acrobat SDK and JavaScript, General troubleshooting, How to, PDF forms

Views

481

Likes

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

How to bold text in JavaScript

Feb 13, 2020

Copy link to clipboard

Copied

I have the following code which is just draft at the moment as I build it up, but I want to bold the text when the checkbox value is on:

 

if(event.target.value=="Off"){ this.getField("Text11").value = "Hmmm"; } else { this.getField("Text11").value = "WORK"; }

 

So, in this instance when the box is ticked I want the 'Text11' field to display 'WORK' which it is doing, but I want that text to be bold.

 

Can someone help me with the code for doing this?

TOPICS
Acrobat SDK and JavaScript, General troubleshooting, How to, PDF forms

Views

482

Likes

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
Feb 13, 2020 0
Feb 13, 2020

Copy link to clipboard

Copied

In Acrobat, the font style goes with the font. So an easy way to do this is to select one of  the Type1 fonts like Helvetica, then uses the checkbox to switch it to Helvetica Bold.

 

Another way to do this is to use Rich Text. This is more complicated, but it allows you to bold any font.

Here's a link to the Acrobat JavaScript Reference to the Span object, which is used to create Rich Text:

https://help.adobe.com/en_US/acrobat/acrobat_dc_sdk/2015/HTMLHelp/#t=Acro12_MasterBook%2FJS_API_Acro...

 

 

Likes

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
Reply
Loading...
Feb 13, 2020 0