These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Changing font and font size in fields with JavaScript. No can do!!

StevenD
Registered: Oct 6 2006
Posts: 368

I have been looking and looking and looking in the LiveCycle Designer ES help for something on changing the font and or at least the font size using JavaScript.

I don't think it can be done. :-P :-(

Would someone please verify this and if it can be done let me at least know where to look for how to do it.

StevenD

My Product Information:
LiveCycle Designer, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
The font type and size can be found in the "font" property of both fields and static text objects.

Ex:
StaticText1.font.typeface;
TextField1.font.size;

To change the text size:

TextField1.font.size = "20pt";

Note however that after the value is changed for the first time you have to kick the form in some way to redraw the element. Static elements don't seem to need kicking.

The only works of course for dynamic forms. Static forms will not redraw themselves or change size parameters of anything on the form.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

StevenD
Registered: Oct 6 2006
Posts: 368
Thanks for the reply Thom.

Here is part of what is throwing me off. LCD ES Helps says this about font property.

A measurement specifying the size of the check box or radio button outline representing either the height and width for a check box, or the diameter for a radio button.

I have tried these lines of code to see if I can get anything to happen.

bodyBlock.font.size = "10pt";

Since the button I am working with is in another subform I have also used this line.
article.FORM_MainPageSF.bodyBlock.font.size = "10pt";

I have also tried several things to kick the form to get it to change but nothing is working. Any suggestions there?

StevenD

thomp
Expert
Registered: Feb 15 2006
Posts: 4411
First, I don't see how the Help file could say this about the font property. It seems awfully odd to say the font is specifically related to the size of a check box. Must be a typo.

Ok I'm assuming that "bodyBlock" is a form field? Is this form dynamic? Also, you know the default text size is 10pt. Have you tried other values?

You should be able to manally kick the form by clicking around on different elements.

BTW: I haven't tried this on Acrobat 9 yet. It may be the problem, it's got a lot of them. I did my testing on Acrobat 8.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

StevenD
Registered: Oct 6 2006
Posts: 368
Yes bodyBlock is a text field and the form is dynamic.

I am working in Acrobat 9 which as you say has lots of problems. I'm not a great bug reporter but I think I may have reported more bugs with Acrobat 9 than I did with 8. I wonder when an update is going to come out. Anyway I am going to try some more things out.

StevenD

StevenD
Registered: Oct 6 2006
Posts: 368
OK. It does work. Just not with rich text fields. I was hoping I could fullfill a client request to be able to reset the text size to be the same point size after someone copies and pastes text from another app into a rich text field but it looks like that is a no no. There is no user interface to control font size.

I am a bit disapointed that rich text fields in XFA forms are not as robust when working with them in Acrobat. As far as I am able to work with this form the only options in changing the text are Bold, Italic, Underline, Superscript, and Subscript unlike a rich text fields in Acroforms which give the user options for color, size, paragraph indents and spacing etc.

Thanks for the help.

StevenD

thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Hmm, I can see why it wouldn't work with a rich text field. The font formatting in a field of this type is supposed to come from the content in the field, not the properties of the field. The text is supposed to be built with Rich Text operators.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script