cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamically Adjusting the Font of Field based on length of vaule - Adobe forms

former_member201527
Participant
0 Kudos

Hello Experts,

 

  I have a requirement where in i need to adjust the font of the field dynamically based on the length of the value.

There is a less space in the adobe form layout and if there is long length (Above 50 Char) value coming then it is showing in multiple lines overlapping on another field.

I just want to dynamically pass the Font to field.

BR,

Nikhil Kulkarni

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

That's easy using Javascript:

You can use e.g. the layou_ready event of the control to be formatted and add some JavaScript:

get the lenght of the text:

... String(yourtextfield).lenght ...

then format the text:

yourtextfield.font.size = "8pt";

regards

Sven

former_member201527
Participant
0 Kudos

Hello Sven,

  Thanks alot for your reply. My field name is AGR_NAME  , so i am writing the following logic and is not working. Please correct me where i am going wrong. Many thanks.

agr_name   is my field name.

data.#pageSet[0].Page1.AGR_NAME::ready:layout - (JavaScript, client)

var len;

len = agr_name.length;

if (len < 3)

{

this.font.size = "20"; 

}else {

this.font.size = "3";

}


Do i need to change some thing in the above java script code which i have written in Layout:ready language : Java script Run at : Client.



BR,

Nikhil Kulkarni

former_member201527
Participant
0 Kudos

Hello Sven Messmer ,

  I wrote this one and still no change in the layout. All components for Java script is in place.  I checked hiding of fields and it worked.

Below is the Code.  Its not working.  I tried specifying font as 20pt  and 20. Both didnot reflect.

data.#pageSet[0].Page1.AGR_NAME::ready:layout - (JavaScript, client)

var len;

len = string(this.AGR_NAME).length;

if (len < 3)

{

this.font.size = "20pt"; 

}else {

this.font.size = "3pt";

}

BR,

Nikhil Kulkarni

Former Member
0 Kudos

Hi,

For me this works perfectly: this.font.size = "10pt";

It works in both master page and content. It seems like your field is in the master page.

May be you can check if your length is returned correctly. --> use an additional textfield to output the length for testing.

An additional check to do:

In transaction SFP, Menu Utilities -> Settings, switch trace level to "Very detailed trace". Once displaying your form in preview mode, check the attachment "error.pdf" --> here you'll find script errors if there are some.

regards

Sven

former_member531036
Participant
0 Kudos

Hi Nikhil,

I've just recently worked on a few forms that were copied from SAP that had this exact code (in FormCalc). Within the initilize event:

var ln = Len($.rawValue)

if (ln <= 125) then

$.font.size = "8 pt"

elseif (ln <=135) then

$.font.size = "7 pt"

else

$.font.size = "6 pt"

$.para.lineHeight = "7 pt"

endif

Julie

Former Member
0 Kudos

Hi Nikhil,

Can you put a TextField onto the screen and on the Initialize event of that TextField put the following JavaScirpt code:

this.rawvalue = string(this.AGR_NAME).length;

This way you can check the value returned, maybe you have to build an extra check and is "len < 3" not enough.

Kind regards,

Niels De Greef

Answers (0)