Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Maximum font size script

Avatar

Avatar
Level 1
radugbhr
Level 1

Likes

0 likes

Total Posts

17 posts

Correct Reply

0 solutions
View profile

Avatar
Level 1
radugbhr
Level 1

Likes

0 likes

Total Posts

17 posts

Correct Reply

0 solutions
View profile
radugbhr
Level 1

22-01-2015

Howdy all!  Have a tricky question. Using LiveCycle ES 8.2

Working on a form, I've got a pair of linked text fields (global data linked).

These text fields are static in size, but I need the values typed into them to shrink when it fills up the visible area of the text field.  I can't set the value font size to 0pt from the start.  It makes the initial font size too big for the value.  The font size needs to remain at 16 pt until the value fills up the field's visible area, then it needs to switch over to 0pt (hence triggering a full event).

I've tried using a full event with the following code;

  1. this.font.size = "0pt";

But it won't fire.  I wonder if there is a limitation to the what the full event can trigger.  I can use the change event or even the exit event if I have to.

I've also tried a calculate event with the following script:

  1. if (this.rawValue.length > 48) {
  2.      this.font.size = "0pt";
  3. }
  4. else {
  5.      this.font.size = "16pt";
  6. }

But this did not fire as well.  And yes, I have the scripting set to Javascript...not Formcalc.


Any suggestions?

Accepted Solutions (0)

Answers (23)

Answers (23)

Avatar

Avatar
Level 1
radugbhr
Level 1

Likes

0 likes

Total Posts

17 posts

Correct Reply

0 solutions
View profile

Avatar
Level 1
radugbhr
Level 1

Likes

0 likes

Total Posts

17 posts

Correct Reply

0 solutions
View profile
radugbhr
Level 1

25-02-2015

Using the script you gave me for the change event (xfa.resolveNode("TitleField0").rawValue = xfa.event.newText),

I decided to try a different approach.  Since the change event on TitleField1 will now change the rawValue on TitleField0, I thought maybe if I put the following script in the change event on TitleField1 , it would trigger onto TitleField0 correctly.  So far it hasn't, but maybe I'm writing it wrong?

if (form1.Card_order_form.Proof_card.TitleField1.rawValue.length < 36)

    {

    form1.Card_order_form.Proof_card.TitleField0.font.size = "9pt";

}

else

    {

    form1.Card_order_form.Proof_card.TitleField0.font.size = "0pt";

}

Avatar

Avatar
Level 1
radugbhr
Level 1

Likes

0 likes

Total Posts

17 posts

Correct Reply

0 solutions
View profile

Avatar
Level 1
radugbhr
Level 1

Likes

0 likes

Total Posts

17 posts

Correct Reply

0 solutions
View profile
radugbhr
Level 1

24-02-2015

Any more avenues we can try?

Avatar

Avatar
Level 1
radugbhr
Level 1

Likes

0 likes

Total Posts

17 posts

Correct Reply

0 solutions
View profile

Avatar
Level 1
radugbhr
Level 1

Likes

0 likes

Total Posts

17 posts

Correct Reply

0 solutions
View profile
radugbhr
Level 1

19-02-2015

It does for the name fields.  It's the title fields which are still troublesome.

After looking at it further, I wouldn't have an issue with making TitleField[0] expand vertically to fit the multiple lines of text.  The idea being to do what you said.  Use the initial height of the field to limit the auto font size when the title is only one line, then have it expand to two lines when the title is long enough.  Just not sure how to accomplish it.  I've never used expand height to fit before. 

Avatar

Avatar
Boost 50
MVP
_Bruce_Robertson
MVP

Likes

270 likes

Total Posts

1,782 posts

Correct Reply

372 solutions
Top badges earned
Boost 50
Boost 5
Boost 3
Boost 250
Boost 25
View profile

Avatar
Boost 50
MVP
_Bruce_Robertson
MVP

Likes

270 likes

Total Posts

1,782 posts

Correct Reply

372 solutions
Top badges earned
Boost 50
Boost 5
Boost 3
Boost 250
Boost 25
View profile
_Bruce_Robertson
MVP

19-02-2015

Does my sample above work for you?

Avatar

Avatar
Level 1
radugbhr
Level 1

Likes

0 likes

Total Posts

17 posts

Correct Reply

0 solutions
View profile

Avatar
Level 1
radugbhr
Level 1

Likes

0 likes

Total Posts

17 posts

Correct Reply

0 solutions
View profile
radugbhr
Level 1

19-02-2015

I tried both.  Both those worked to copy the raw value from TitleField[1] to TitleField[0] without global data binding, but TitleField[0] still won't change it's font size to 0 when the field is full.

I used the xfa.resolveNode("TitleField[0]").font.size = "0pt"; on the full event of TitleField [0] with the limit to visible area option checked.

Avatar

Avatar
Boost 50
MVP
_Bruce_Robertson
MVP

Likes

270 likes

Total Posts

1,782 posts

Correct Reply

372 solutions
Top badges earned
Boost 50
Boost 5
Boost 3
Boost 250
Boost 25
View profile

Avatar
Boost 50
MVP
_Bruce_Robertson
MVP

Likes

270 likes

Total Posts

1,782 posts

Correct Reply

372 solutions
Top badges earned
Boost 50
Boost 5
Boost 3
Boost 250
Boost 25
View profile
_Bruce_Robertson
MVP

18-02-2015

Sure,

Try this JavaScript in the exit event of TitleField[1]

xfa.resolveNode("TitleField[0]").rawValue = this.rawValue;

or this in the change event

xfa.resolveNode("TitleField[0]").rawValue = xfa.event.newText

Avatar

Avatar
Level 1
radugbhr
Level 1

Likes

0 likes

Total Posts

17 posts

Correct Reply

0 solutions
View profile

Avatar
Level 1
radugbhr
Level 1

Likes

0 likes

Total Posts

17 posts

Correct Reply

0 solutions
View profile
radugbhr
Level 1

15-02-2015

Yeah, TitleField[0] and TitleField[1] are both set to Use Global Data for their Data Binding.  That way I can set TitleField[0] to protected or Read-Only and have it populated with the data values from TitleField[1].  Seeing as TitleField[0] is populated via global data binding, is there another option I have to check to force TitleField[0]'s scripts to fire correctly?

Avatar

Avatar
Boost 50
MVP
_Bruce_Robertson
MVP

Likes

270 likes

Total Posts

1,782 posts

Correct Reply

372 solutions
Top badges earned
Boost 50
Boost 5
Boost 3
Boost 250
Boost 25
View profile

Avatar
Boost 50
MVP
_Bruce_Robertson
MVP

Likes

270 likes

Total Posts

1,782 posts

Correct Reply

372 solutions
Top badges earned
Boost 50
Boost 5
Boost 3
Boost 250
Boost 25
View profile
_Bruce_Robertson
MVP

15-02-2015

Maybe, I didn't have that in my version.

Avatar

Avatar
Level 1
radugbhr
Level 1

Likes

0 likes

Total Posts

17 posts

Correct Reply

0 solutions
View profile

Avatar
Level 1
radugbhr
Level 1

Likes

0 likes

Total Posts

17 posts

Correct Reply

0 solutions
View profile
radugbhr
Level 1

15-02-2015

Tried  xfa.resolveNode("TitleField[0]").font.size = "0pt"; in the full event on Title[0]. Also checked the Limit length to visible area for both Title Fields [0] and [1].  Still isn't firing.  I'm wondering if it's because I have title field [1] populating title field [0] via global data binding between the 2?

Avatar

Avatar
Boost 50
MVP
_Bruce_Robertson
MVP

Likes

270 likes

Total Posts

1,782 posts

Correct Reply

372 solutions
Top badges earned
Boost 50
Boost 5
Boost 3
Boost 250
Boost 25
View profile

Avatar
Boost 50
MVP
_Bruce_Robertson
MVP

Likes

270 likes

Total Posts

1,782 posts

Correct Reply

372 solutions
Top badges earned
Boost 50
Boost 5
Boost 3
Boost 250
Boost 25
View profile
_Bruce_Robertson
MVP

14-02-2015

Sorry should have been

xfa.resolveNode("TitleField[0]").font.size = "0pt";

That's instance zero of TitleField, you will also need to have a Limit Length ... max chars or Limit Length to Visible Area set on TitleField[1]

Regards

Bruce

Avatar

Avatar
Level 1
radugbhr
Level 1

Likes

0 likes

Total Posts

17 posts

Correct Reply

0 solutions
View profile

Avatar
Level 1
radugbhr
Level 1

Likes

0 likes

Total Posts

17 posts

Correct Reply

0 solutions
View profile
radugbhr
Level 1

13-02-2015

Tried  xfa.resolveNode("TitleField[1]").font.size = "0pt"; in the full event on Title[0].  No dice.  I don't think the full event will run such a javascript.  That's why I was thinking maybe put it in it's own script object then have the full event run that script object. 

Avatar

Avatar
Boost 50
MVP
_Bruce_Robertson
MVP

Likes

270 likes

Total Posts

1,782 posts

Correct Reply

372 solutions
Top badges earned
Boost 50
Boost 5
Boost 3
Boost 250
Boost 25
View profile

Avatar
Boost 50
MVP
_Bruce_Robertson
MVP

Likes

270 likes

Total Posts

1,782 posts

Correct Reply

372 solutions
Top badges earned
Boost 50
Boost 5
Boost 3
Boost 250
Boost 25
View profile
_Bruce_Robertson
MVP

12-02-2015

Try this JavaScript in the full event;

xfa.resolveNode("TitleField[1]").font.size = "0pt";

Regards

Bruce

Avatar

Avatar
Level 1
radugbhr
Level 1

Likes

0 likes

Total Posts

17 posts

Correct Reply

0 solutions
View profile

Avatar
Level 1
radugbhr
Level 1

Likes

0 likes

Total Posts

17 posts

Correct Reply

0 solutions
View profile
radugbhr
Level 1

12-02-2015

Working better.  But I wonder if I can write a script that is triggered on a full event for the Title field.

Then have the script execute something like:

form1.Card_order_form.#variables[0].change_font_size - (JavaScript, client)

xfa.host.setFocus(form1.Card_order_form.Proof_card.TitleField);

    this.font.size = "0pt";

Avatar

Avatar
Boost 50
MVP
_Bruce_Robertson
MVP

Likes

270 likes

Total Posts

1,782 posts

Correct Reply

372 solutions
Top badges earned
Boost 50
Boost 5
Boost 3
Boost 250
Boost 25
View profile

Avatar
Boost 50
MVP
_Bruce_Robertson
MVP

Likes

270 likes

Total Posts

1,782 posts

Correct Reply

372 solutions
Top badges earned
Boost 50
Boost 5
Boost 3
Boost 250
Boost 25
View profile
_Bruce_Robertson
MVP

11-02-2015

Hi,

I probably still not following, but with the "allow multiple lines" you can still get the auto fit thing happening.

Hopefully this will work this time, https://sites.google.com/site/livecycledesignercookbooks/home/bizcard_form.1.pdf?attredirects=0&d=1

Seemed to be something funny in the Imprint_header rich text before.

I think if someone has a long name and a short title, the name will be shrunk less than the title.  Maybe you can +/- buttons for the users to adjust the font size manually.

Regards

Bruce

Avatar

Avatar
Level 1
radugbhr
Level 1

Likes

0 likes

Total Posts

17 posts

Correct Reply

0 solutions
View profile

Avatar
Level 1
radugbhr
Level 1

Likes

0 likes

Total Posts

17 posts

Correct Reply

0 solutions
View profile
radugbhr
Level 1

10-02-2015

Ahhh...I see what you're saying.  My issue is more with the bottom field.  [Title]

Just tried setting the font size to 0 in ES2.  It does max the font size to the height of the field.

But with the bottom field, I only have so much room to work with.  There are other fields below the Title field.  So I can't set it to expand on demand.

What I've wanted it to do is hit a certain character limit (36), then switch from 9pt to 0 pt.  But I have the "allow multiple lines" option checked in the object properties to allow the Title field to take up to 2 lines if necessary.  I can't limit to a character count or visible area since it won't break onto multiple lines then.

Hence why I want to see if there's a change or full script that will change the font size to 0.

PS: I have the Title field on the left set to read only.  It gets populated with its values from the title field on the right. 

Avatar

Avatar
Boost 50
MVP
_Bruce_Robertson
MVP

Likes

270 likes

Total Posts

1,782 posts

Correct Reply

372 solutions
Top badges earned
Boost 50
Boost 5
Boost 3
Boost 250
Boost 25
View profile

Avatar
Boost 50
MVP
_Bruce_Robertson
MVP

Likes

270 likes

Total Posts

1,782 posts

Correct Reply

372 solutions
Top badges earned
Boost 50
Boost 5
Boost 3
Boost 250
Boost 25
View profile
_Bruce_Robertson
MVP

09-02-2015

I think the maximum font size will be determined by the height of the field.  This seems ok in your simplified version, is this not the case in the real form?

Regards

Bruce

Avatar

Avatar
Level 1
radugbhr
Level 1

Likes

0 likes

Total Posts

17 posts

Correct Reply

0 solutions
View profile

Avatar
Level 1
radugbhr
Level 1

Likes

0 likes

Total Posts

17 posts

Correct Reply

0 solutions
View profile
radugbhr
Level 1

09-02-2015

Still isn't opening up.  I am running Reader XI and Acrobat 9 Pro (9.4) on my system.  So I don't think either one should have any problems with compatibility.

So, in LiveCycle ES2, is there an option to change this reasonable maximum font size?  Like can it be customized to a field, the whole form, or is it coded globally for all XFA PDFs?

Avatar

Avatar
Boost 50
MVP
_Bruce_Robertson
MVP

Likes

270 likes

Total Posts

1,782 posts

Correct Reply

372 solutions
Top badges earned
Boost 50
Boost 5
Boost 3
Boost 250
Boost 25
View profile

Avatar
Boost 50
MVP
_Bruce_Robertson
MVP

Likes

270 likes

Total Posts

1,782 posts

Correct Reply

372 solutions
Top badges earned
Boost 50
Boost 5
Boost 3
Boost 250
Boost 25
View profile
_Bruce_Robertson
MVP

09-02-2015

Hi,

Try this version of the form, is has the compatibility set to Reader 8. https://sites.google.com/site/livecycledesignercookbooks/home/bizcard_form.1.pdf?attredirects=0&d=1

There seems to be a reasonable maximum font, that is what I meant to point out in my first image above, which looks to me to be 9.5

Regards

Bruce

Avatar

Avatar
Level 1
radugbhr
Level 1

Likes

0 likes

Total Posts

17 posts

Correct Reply

0 solutions
View profile

Avatar
Level 1
radugbhr
Level 1

Likes

0 likes

Total Posts

17 posts

Correct Reply

0 solutions
View profile
radugbhr
Level 1

09-02-2015

Can't open the form.  It gives me an "Error encountered while processing node...Unable to find a suitable font ISO 8859-6 encoding message.  Both Reader and Acrobat.

In any event, if I were to use ES2 or later, and set the font value to 0, wouldn't the field value try and take up the entire text box then?

Avatar

Avatar
Boost 50
MVP
_Bruce_Robertson
MVP

Likes

270 likes

Total Posts

1,782 posts

Correct Reply

372 solutions
Top badges earned
Boost 50
Boost 5
Boost 3
Boost 250
Boost 25
View profile

Avatar
Boost 50
MVP
_Bruce_Robertson
MVP

Likes

270 likes

Total Posts

1,782 posts

Correct Reply

372 solutions
Top badges earned
Boost 50
Boost 5
Boost 3
Boost 250
Boost 25
View profile
_Bruce_Robertson
MVP

09-02-2015

Hi,

Using ES3 and just a 0 font initially (with all scripting removed) I get the following, for a short name;

Short Name.PNG

Which seems about the right.

And for a long name

Long Name.PNG

My version of your form is here https://sites.google.com/site/livecycledesignercookbooks/home/bizcard_form.1.pdf?attredirects=0&d=1

There have been some changes since ES8, including a default font size added to the form properties, but not sure that is a factor as the largest font used in this sample is still smaller than the default.

Is this what you are seeing?

Bruce

Avatar

Avatar
Level 1
radugbhr
Level 1

Likes

0 likes

Total Posts

17 posts

Correct Reply

0 solutions
View profile

Avatar
Level 1
radugbhr
Level 1

Likes

0 likes

Total Posts

17 posts

Correct Reply

0 solutions
View profile
radugbhr
Level 1

06-02-2015

Here's the dumbed down version.

bizcard_form.pdf - Google Drive

Its the name and title fields which I'm trying to set the maximum font size to.  There are two of each field, both have their values linked globally, but not their formatting.  So, the left hand fields I need to set a different font size than the right hand fields. 

Avatar

Avatar
Level 1
radugbhr
Level 1

Likes

0 likes

Total Posts

17 posts

Correct Reply

0 solutions
View profile

Avatar
Level 1
radugbhr
Level 1

Likes

0 likes

Total Posts

17 posts

Correct Reply

0 solutions
View profile
radugbhr
Level 1

27-01-2015

How are you setting it though?  What script?

I can't post the form without getting a bunch of OKs first (gotta love government).

But I will replicate the text fields I'm trying to do this in and post that in a pdf. 

Avatar

Avatar
Boost 50
MVP
_Bruce_Robertson
MVP

Likes

270 likes

Total Posts

1,782 posts

Correct Reply

372 solutions
Top badges earned
Boost 50
Boost 5
Boost 3
Boost 250
Boost 25
View profile

Avatar
Boost 50
MVP
_Bruce_Robertson
MVP

Likes

270 likes

Total Posts

1,782 posts

Correct Reply

372 solutions
Top badges earned
Boost 50
Boost 5
Boost 3
Boost 250
Boost 25
View profile
_Bruce_Robertson
MVP

27-01-2015

Hi,

This might be something funny with ES 8.  I have ES 9 and ES 10 and both seem to set the max font size to 12 points.  If you can post a link to your form I can see what is happening in one of the newer versions.

Regards

Bruce