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

What is the script I can use to change the font in a textfieldin

Participant ,
Apr 14, 2021 Apr 14, 2021

Copy link to clipboard

Copied

Hi everyone, I would like to change the font in  a text field.

It´s not a global change. It would affect only a specific group of text fields in a given

page.

 

I found the script: this.getField("Textfield").textFont = "Font name"

 

but it is not working. Please let me know if I´m doing anything wrong.

Thanks a lot!!

TOPICS
Create PDFs , How to , JavaScript , PDF forms

Views

458

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 , Apr 15, 2021 Apr 15, 2021

The code seems fine. The tricky part is knowing the actual internal name of the font you want to use, as you can't just use the name that appears in the font selection list.

The best way of finding out that name is by manually assigning this font to a field (let's say it's called "Text1") and then running this code from the JS Console:

 

this.getField("Text1").textFont;

 

It will print out the internal name of that font, and you can then use that in your real script to apply it to other fields i

...

Votes

Translate

Translate
Community Expert ,
Apr 14, 2021 Apr 14, 2021

Copy link to clipboard

Copied

You may want to share the exact script thatis not working for your or an example of that PDF in order to get better assistance.

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 ,
Apr 14, 2021 Apr 14, 2021

Copy link to clipboard

Copied

What happens when you use the script? Any error in the Javascript console?

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 ,
Apr 15, 2021 Apr 15, 2021

Copy link to clipboard

Copied

The code seems fine. The tricky part is knowing the actual internal name of the font you want to use, as you can't just use the name that appears in the font selection list.

The best way of finding out that name is by manually assigning this font to a field (let's say it's called "Text1") and then running this code from the JS Console:

 

this.getField("Text1").textFont;

 

It will print out the internal name of that font, and you can then use that in your real script to apply it to other fields in the file.

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
Participant ,
Apr 15, 2021 Apr 15, 2021

Copy link to clipboard

Copied

LATEST

Thanks a lot for yor tip and advice!

 

The problem was: My desired font´s name has two words. Using your method, I found out that

it is actually written as one word. Now, everything worked perfectly!!

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