tbone56 Posted December 16, 2010 Share Posted December 16, 2010 I want to change the color of a text field based on a value in a cell in the data sheet. The text in the cell is constant but I need to be able to change the colors of that text. Any of you guys know how to do this? Link to comment Share on other sites More sharing options...
Alex Marshall Posted December 16, 2010 Share Posted December 16, 2010 You certainly can. It just involves two simple and fast steps: 1. In Acrobat, go to FusionPro > Advanced > Colors and add the spot color as a new color (unless you did so already in InDesign or Quark). Make sure that, when added, you checked the box "Spot". 2. Write your rule using the "name" attribute of the color tag --> <color name ="NameofColor"> And, of course, make sure that "Treat returned strings as tagged text" is checked. Link to comment Share on other sites More sharing options...
tbone56 Posted December 16, 2010 Author Share Posted December 16, 2010 Ok. I think I figured out how it is supposed to work but I can't get it to work. I have the rule written, and it works in the sense that it changes the font correctly (to Porcelain), but it does not change the color. I have created two new colors and loaded the font. They seem to be working becuase in the Text Editor, I can use the font and apply the colors. Here is the code I have: if (Field("FrontFont") == String("9FrontFont1Bw")) { return "<span>" + "<f name=Porcelain>" + "<color name=PD Logo Brown>" + String("TESTING FONT") + "</span>"; } return ""; Link to comment Share on other sites More sharing options...
tbone56 Posted December 16, 2010 Author Share Posted December 16, 2010 Sorry Alex. I didnt see you post before the last one. It didn't refresh. But, I have it working now. I guess you cannot have spaces in Font names? Link to comment Share on other sites More sharing options...
Dan Korn Posted December 16, 2010 Share Posted December 16, 2010 I guess you cannot have spaces in Font names? Yes, you can absolutely have spaces in font and color names. But you have to enclose the attributes in double-quotes in tagged markup so that the parser knows to include the spaces. Try this instead: return '<span><f name="Porcelain"><color name="PD Logo Brown">TESTING FONT</span>';If the name of the color is contained in a data field, you can do something like this instead: return '<span><f name="Porcelain"><color name="' + Field("YourColorFieldName") + '">TESTING FONT</span>'; Link to comment Share on other sites More sharing options...
tbone56 Posted December 16, 2010 Author Share Posted December 16, 2010 Thanks for the help. As you can tell, I am very new to this and have never used code so what I posted was what FPD gave me from the wizard. Some of what I have read about what this can do is impressive. I could use alot of it but I don't quite understand it all. With that, Dan, your second sample about pulling color from data field does not have all the "" and +'s like like the others. Do those really matter or are both considered proper syntax? I have been fiddling with a few other things and will test it out later today. It looks to be perfect for what I need. Link to comment Share on other sites More sharing options...
Dan Korn Posted December 16, 2010 Share Posted December 16, 2010 With that, Dan, your second sample about pulling color from data field does not have all the "" and +'s like like the others. Do those really matter or are both considered proper syntax? Both are proper syntax for JavaScript, but double-quotes are required in the returned string for the tag attributes for FusionPro. So, I purposefully used single quotes around the entire string, so that I could use literal double-quotes within the string without having to resort to a more complicated escape syntax. I could have done this instead:return "<span><f name=\"Porcelain\"><color name=\"" + Field("YourColorFieldName") + "\">TESTING FONT</span>";But as you can see, that requires the use of the backslash character to denote to JavaScript that you want to include a literal double-quote inside the string instead of ending the string. I was also just simplifying the code a bit; you don't need to concatenate multiple literal strings with the plus sign, you can just put them into one longer string literal. These two lines are the same: return "Here " + "is " + "a " + "long " + "string"; // is the same as return "Here is a long string"; The generated code that the Rule Wizard produces is more verbose that what you need to do if you're writing a rule yourself. For more information on JavaScript string literals, please refer to the JavaScript Guide: https://developer.mozilla.org/en/JavaScript/Guide/Values%2c_Variables%2c_and_Literals#String_Literals Link to comment Share on other sites More sharing options...
tbone56 Posted December 17, 2010 Author Share Posted December 17, 2010 Hey guys, I got another question. I have a text field pulling in data for peoples names and now I need to chnage the color of the names based on another field. If I am not clear, this is different becuase prevously the text in the field was a constant. Can either of you guys help me out? I assume it is very similar to the code I have, but I can't get it to work right. Thanks ahead of time. Link to comment Share on other sites More sharing options...
esmith Posted December 21, 2010 Share Posted December 21, 2010 Modifying the 2nd code snippet in Dan's first post to this thread, you would just replace the static text with the field containing your variable text: return '<span><f name="Porcelain"><color name="' + Field("YourColorFieldName") + '">' + Field("YourText") + '</span>'; Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.