Skip to main content
Inspiring
June 9, 2021
Question

Javascript for Acrobat form field instructions

  • June 9, 2021
  • 2 replies
  • 793 views

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:

 

 

 

 

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

This topic has been closed for replies.

2 replies

Thom Parker
Community Expert
Community Expert
June 9, 2021

See this article and watch the vidoes:

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

 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
try67
Community Expert
Community Expert
June 9, 2021

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";