Skip to main content
Participant
March 29, 2024
Question

I want to set the text field font size to adjust automatically with a maximum limit of font size 9

  • March 29, 2024
  • 3 replies
  • 3246 views

Hi,

I have the option to set the font size to auto, which will adjust the font size automatically based on the text content in text fields (used in prepay forms). Alternatively, I can manually set the font size to 9 or any specific value. However, what I specifically need is to set the font size to adjust automatically within a range, with the maximum font size capped at 9. This means that the font size will automatically adjust between 1 and 9, depending on the content.

I require this functionality because sometimes I have a large multi-line text field with only a short text, such as "Hi". In such cases, the text appears excessively large on the PDF, which looks unattractive. Therefore, I want to ensure that even for short text like "Hi", the font size remains at or below 9.

3 replies

JR Boulay
Community Expert
Community Expert
September 16, 2024

Do as I do, create a field with text in size 14, place another field next to it with text in automatic size and adjust its height until it matches the text in size 14.

Acrobate du PDF, InDesigner et Photoshopographe
JR Boulay
Community Expert
Community Expert
April 10, 2024

TIP: the maximum text size is relative to the height of the field.

😉

 

Acrobate du PDF, InDesigner et Photoshopographe
Participant
April 11, 2024

Hi, yes, I'm aware of that. The text field height, for example, is set to 0.92cm. This means the maximum text font size can be 18. However, I want to limit the maximum font size to 9 and the minimum to 3 for that text field.

Nesa Nurani
Community Expert
Community Expert
March 29, 2024

You could do it with a script, by using the number of characters in the field for reference, for example if characters are between 1-5 set size to 9 if between 6-10 set size to 8...etc you can do it using textSize property like this validate script:

var str = event.value;
if(str.length >=1 && str.length <=5)
event.target.textSize = 9;
else if(str.length >=6 && str.length <=10)
event.target.textSize = 8;

Participant
March 29, 2024

Hi, that approach won't work for my situation. I have various text fields of different sizes, and the inserted data lengths vary as well.

Nesa Nurani
Community Expert
Community Expert
March 29, 2024

So what are your conditions for text size?