These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Script for automatic text resizing to fit in text field?

Ardid
Registered: Nov 14 2010
Posts: 6
Answered

Help, please!
 
I want to make a multiline text field with a pre-fixed font size (8 pt), but I want it to reduce automatically if needed to fit the text box, as if it was set in automatic font size. Is it possible? Is there any script to make this? The estimated length of the text in 8 pt should be 50 characters.
 
Thank you in advance,
 
Ardid
 

 
P.S. I am using Acrobat 9 Pro Mac

My Product Information:
Acrobat Pro 9.0, Macintosh
try67
Expert
Registered: Oct 30 2008
Posts: 2398
It's possible to write a script that looks at the length of the text and changes the font-size based on it.
For example, you can use something like this as the validation script:

if (event.value.length>50) event.target.textSize = 8;
else if (event.value.length<50) event.target.textSize = 12;

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

Ardid
Registered: Nov 14 2010
Posts: 6
Accepted Answer
Though you have to go out of the field to see the text fitting, it works!! Based on your script I set the text size to 0 to make it automatically shrink to fit if the text is longer than 50, and 8 pt size if the text is shorter. So:

if (event.value.length>50) event.target.textSize = 0;
else if (event.value.length<50) event.target.textSize = 8;Thank you very much!

Ardid