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

Javascript for Acrobat form field instructions

Explorer ,
Jun 09, 2021 Jun 09, 2021

Copy link to clipboard

Copied

I'm trying to add instructional text to my form fields in Acrobat Pro DC. I found these two helpful resources that allowed me to set up the code:

  1. https://answers.acrobatusers.com/How-create-disappearing-instruction-text-fields-q303265.aspx
  2. https://www.youtube.com/watch?v=F1VwOMTlI3Q 

 

Now I'm trying to figure out how to set the specific font and size for that instructional text. My current script is:

 

if(event.value=="")

{ event.value="Instructional text goes here..."; font.size = "10pt"; }

 

That results in the following:

Screen Shot 2021-06-09 at 4.26.28 PM.png

 

 

 

 

Now I just need to change the font and size so it fits better. What script/code can I add? Can anyone help?

TOPICS
PDF forms

Views

468

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 ,
Jun 09, 2021 Jun 09, 2021

Copy link to clipboard

Copied

This code is incorrect:

font.size = "10pt";

Use this, instead:

event.target.textSize = 10;

And to set the font you need to know the internal name of it, and then apply it to the textFont property, like this:

event.target.textFont = "Arial";

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 ,
Jun 09, 2021 Jun 09, 2021

Copy link to clipboard

Copied

LATEST

See this article and watch the vidoes:

https://www.pdfscripting.com/public/Editing-Fields-Properties.cfm

 

 

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

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