Expand my Community achievements bar.

Code/Action to Change Textbox Value Font Size

Avatar

Level 2

I have a form with textboxes in which the user types in information.  Sometimes, the user will type in more information than can fit into the textbox.  When this happens, I would like the textbox font to become smaller so that the typed in text fits into the textbox.  I need the textbox length to stay fixed.  Any suggestions for coding or Actions to make the text font size do this  - either a) automatically, or b) by the user clicking something?

5 Replies

Avatar

Level 10

Hi,

You will get to choose when you want to change text's font.

All you need to do is create a string which declares xml header + your text in html format...

The object you want to insert different font requires exData instead of Text, so you need to have 2 different fonts originally in your text (e.g. you can have 2 spaces with 1 bold and 1 normal) or create a node for exData...

Now in your code you will need your XML string which should look like this

Then use your textbox / text to load the XML you have created...

Avatar

Level 4

The way that I do it is in the Font Window (and the field selected), right above the Font Name and Size there is an arrow button that says "Currently editing Value properties". Click that arrow and select "Edit Value". Then in the Font Size set that to 0. The font size is now decided by the size of the text field. If you put more text into the field than the visible area it will automatically resize the font.

Screenshot.png

Avatar

Level 2

Thank you very much for your responses.

Magus069 response: I have put your code into a button.  After clicking a button, I got an error ("... ExData...") - I found from other threads that I need to change the "Field Format" in the Field tab from Plain text to Rich text-that stopped the error.

Where I am at now is that I need the text the User types in to change in font size.  Do I assign this to a variable and then put that in the XML code?

JoshG response: When I use your method, I get a tiny (1pt?) text size in the text box.  What would work best for me is to start off at 10pt, and then switch to 8, 6 etc. when the text fills the text box.

Thanks again.

Avatar

Level 10

Yess as I said exData requires something in your text, as I said you can just have 2 different font size in your textbox as: 2 spaces; 1 italic and 1 bold... or rich text...

When the user enter the textbox you can set its value to = "";

Only because of the two spaces with 2 different fonts, your textbox will have exData created if you don't want rich text.

And Yess you can assign this to a variable and then put it in the XML code.

You can also use the # for the font-size instead of using larger,x-larger

Go with -> style=\"font-size:16pts;\"

Avatar

Level 2

I ended up do a radio button with 3 different font sizes:

aaa = xfa.resolveNode("S19.SigAdd");

bbb = xfa.resolveNode("S19.AddressSize");

if (bbb.rawValue == "10")

{

aaa.font.size = "10pt";

}

if (bbb.rawValue == "8")

{

aaa.font.size = "8pt";

}

if (bbb.rawValue == "6")

{

aaa.font.size = "6pt";

}


Also found code to use a checkbox for this here:

LiveCycle ES2 * Adobe LiveCycle Designer ES2

Magus069 suggestions worked as well.  I replaced his sample text with a variable, and assigned the rawValue of the textbox box to the variable.