cancel
Showing results for 
Search instead for 
Did you mean: 

Reduce font size automatically in a multiline textfield

dpz_de
Discoverer
0 Kudos

Hi,

i am using a multi line textfield with dynamic text.

I need to reduce the font size automatically when there are too many lines that the text would be cut off.

i know JS code thats counts the characters and reduces the font size if needed:

var len;
len = this.rawValue.length;
if (len>40){
this.font.size = „20pt“;
} else {
this.font.size = „10pt“;
}

But this will not fix my problem due i have to recuce the font not after x charcters but after x lines. Do you have an idea how to count the lines to recudce the font size?

Another idea: In an adobe forum i found the answer "just set font size for this field to 0 and it will determine the correct size automaticaly". But unfortunately i am not able to set the text size to 0.

BR

Accepted Solutions (0)

Answers (1)

Answers (1)

roberto_vacca2
Active Contributor

Hi,

to set font size to 0 you need to use a text-field and try to use last version of livecycle designer; as you can see in the forn palette on the top-left-right, I set 0 as font size.

But that's not the only thing you need to do. To get your automation you'll need to put an 'X' in DYNAMIC option of your sfpdocparams structure, or you'll see nothing.

By the way, if you want to find lines number, you'll need to do a calculation, but this is only an estimation:

var txlen = this.rawValue.length;

var boxwidth = 12; // cm

var boxheight = 16; // cm

var nlines = Math.sqrt( boxheight / ( txlen / boxwidth ) );

I'm struggling too with "auto-size", but it seems there's no a well-known solution.

Have a try, and let me know if you solve it.