Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.

How to change font color of static text?

Avatar

Former Community Member
Hi,



I tried to change the font color of static text using:




xfa.resolveNode("test").caption.font.fill.color.value = "0,0,0";



or




xfa.resolveNode("test").font.fill.color.value = "0,0,0";





Neither resulted in black text.



Am I getting it wrong?

Does anyone have an idea how to change the font color of static text?



Regards,

Steve
9 Replies

Avatar

Former Community Member
Did anyone ever succeed in changing the color of static text?



Steve

Avatar

Former Community Member
Is not possible to put:

xfa.resolveNode("test").fontColor= "0,0,0"; ?

Avatar

Former Community Member
Thank you.



Obviously changing the color of text works with any of these three:




xfa.resolveNode("#subform[0].textfield").fontColor= "0,0,0";

xfa.resolveNode("#subform[0].textfield").font.fill.color.value = "0,0,0";

xfa.resolveNode("#subform[0].textfield").caption.font.fill.color.value = "0,0,0";



Unfortunately, it does NOT work with static text but only with textfields. That's what I get wrong.



Regards,

Steve

Avatar

Former Community Member
I don't believe it's possible to change the color of static text at runtime. You'd need to use a text field, make it read only, and set it's appearance so that it looks like static text to the user.



Chris

Adobe Enterprise Developer Support

Avatar

Former Community Member
Using a text field to work around this problem would not work for me. I am using floating fields within large areas of highly formatted text. I want to change the color of the floating fields within the text.



Here is the only work around I've come up with. In my case, I want the floating text to be blue, then change to black.



1) for each floating text item, add two floating fields side by side like this:



text text {float_field1_colored}{float_field1_black} text text...



2) use the colored field:




float_field1_colored.rawValue = theUserEnteredText;

xfa.layout.relayout();




3) when you want to "change" the color, copy it to the second field and erase the first:




float_field1_black.rawValue = float_field1_colored.rawValue;

float_field1_colored.rawValue = "";

xfa.layout.relayout();

Avatar

Level 6
In case you didn't see the response to another similar thread.



I figured this out. When you create the static text object at design time, make sure that it has a word with a different colour or font or something. That will ensure that its value property contains an exData object with contentType="text/html". Now you can change the contents at run time with (I've replaced the angle brackets with {}):



var theXML = "{body xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:xfa=\"http://www.xfa.org/schema/xfa-data/1.0/\" xfa:APIVersion=\"2.5.6290.0\"}{p style=\"text-decoration:none\"}The{span style=\"xfa-spacerun:yes\"} {/span}{span style=\"color:#ff0000\"}quick{/span} brown fox.{/p}{/body}";



StaticText1.value.exData.loadXML(theXML,true);



Jared Langdon

www.jlangdon.ca

Avatar

Former Community Member
I have a fill colour (yellow) in my fields. How do I stop that colour showing in a black and white printed copy of my form?



Louise Forster

louise@wordsworth.com.au

Avatar

Former Community Member
i am trying this xfa.resolveNode("form1.#subform[0].response").fontColor = firstcolor;

to change the font color when radio button is clicked.it is work nice for plain text field type.when field type is rich text.when we modify the rich text value then this( xfa.resolveNode("form1.#subform[0].response").fontColor = firstcolor;) is not working means color not changed for modify text.if we apply this without modify rich text value then it works mean change the value.



i want to what ever we do with rich text value,it must change the color of text when cliked.

Avatar

Level 1

Text.font.fill.color.value = "153,204,0"