Go Back   MarcomCentral (PTI) and FusionPro User Communities > Support > Fonts

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old December 16th, 2010, 08:33 AM
tbone56 tbone56 is offline
Junior Community Member
 
Join Date: Sep 2010
Posts: 29
Default Changing color of a Text Field based on data value.

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?
Reply With Quote
  #2  
Old December 16th, 2010, 09:05 AM
Alex Marshall's Avatar
Alex Marshall Alex Marshall is offline
FusionPro VDP Support
 
Join Date: Sep 2008
Location: Chicago,Illinois
Posts: 383
Default Re: Changing color of a Text Field based on data value.

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.
Reply With Quote
  #3  
Old December 16th, 2010, 09:07 AM
tbone56 tbone56 is offline
Junior Community Member
 
Join Date: Sep 2010
Posts: 29
Default Re: Changing color of a Text Field based on data value.

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 "";
Reply With Quote
  #4  
Old December 16th, 2010, 09:09 AM
tbone56 tbone56 is offline
Junior Community Member
 
Join Date: Sep 2010
Posts: 29
Default Re: Changing color of a Text Field based on data value.

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?
Reply With Quote
  #5  
Old December 16th, 2010, 10:26 AM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 4,410
Default Re: Changing color of a Text Field based on data value.

Quote:
Originally Posted by tbone56 View Post
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:
Code:
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:
Code:
return '<span><f name="Porcelain"><color name="' + Field("YourColorFieldName") + '">TESTING FONT</span>';
__________________
Dan Korn
FusionPro Developer / JavaScript Guru / Forum Moderator
PTI Marketing Technologies | Printable | MarcomCentral
LinkedIn

I am a not a Support engineer, and this forum is not a substitute for Support. My participation on this forum is primarily as a fellow user (and a forum moderator). I am happy to provide help and answers to questions when I can; however, there is no guarantee that I, or anyone else on this forum, will be able to answer all questions or fix any problems. If I ask for files to clarify an issue, I might not be able to look at them personally. I am not able to answer private messages, emails, or phone calls unless they go through proper Support channels. Please direct any sales or pricing questions to your salesperson or inquiries@marcom.com.

Complex template-building questions, as well as all installation and font questions or problems, should be directed to FusionProSupport@marcom.com. Paid consulting work may be required to fulfill your template-building needs.

This is a publicly viewable forum. Please DO NOT post fonts, or other proprietary content, to this forum. Also, please DO NOT post any "live" data with real names, addresses, or any other personal, private, or confidential data.

Please include the specific versions of FusionPro, Acrobat, and your operating system in any problem reports or help requests. I recommend putting this information in your forum signature. Please also check your composition log (.msg) file for relevant error or warning messages.

Please post questions specific to the MarcomCentral Enterprise and Web-to-Print applications in the MarcomCentral forum. Click here to request access. Or contact your Business Relationship Manager (BRM/CPM) for assistance.

Please direct any questions specific to EFI's Digital StoreFront (DSF) to EFI support.

How To Ask Questions The Smart Way

The correct spellings are JavaScript, FusionPro, and MarcomCentral (each with two capital letters and no spaces). Acceptable abbreviations are JS, FP, and MC (or MCC). There is no "S" at the end of "Expression" or "Printable"! The name of the product is FusionPro, not "Fusion". "Java" is not is not the same as JavaScript.

Check out the JavaScript Guide and JavaScript Reference! FusionPro 8.0 and newer use JavaScript 1.7. Older versions use JavaScript 1.5.

return "KbwbTdsjqu!spdlt\"".replace(/./g,function(w){return String.fromCharCode(w.charCodeAt()-1)});
Reply With Quote
  #6  
Old December 16th, 2010, 12:42 PM
tbone56 tbone56 is offline
Junior Community Member
 
Join Date: Sep 2010
Posts: 29
Default Re: Changing color of a Text Field based on data value.

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.
Reply With Quote
  #7  
Old December 16th, 2010, 01:52 PM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 4,410
Default Re: Changing color of a Text Field based on data value.

Quote:
Originally Posted by tbone56 View Post
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:
Code:
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:
Code:
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/Jav...tring_Literals
__________________
Dan Korn
FusionPro Developer / JavaScript Guru / Forum Moderator
PTI Marketing Technologies | Printable | MarcomCentral
LinkedIn

I am a not a Support engineer, and this forum is not a substitute for Support. My participation on this forum is primarily as a fellow user (and a forum moderator). I am happy to provide help and answers to questions when I can; however, there is no guarantee that I, or anyone else on this forum, will be able to answer all questions or fix any problems. If I ask for files to clarify an issue, I might not be able to look at them personally. I am not able to answer private messages, emails, or phone calls unless they go through proper Support channels. Please direct any sales or pricing questions to your salesperson or inquiries@marcom.com.

Complex template-building questions, as well as all installation and font questions or problems, should be directed to FusionProSupport@marcom.com. Paid consulting work may be required to fulfill your template-building needs.

This is a publicly viewable forum. Please DO NOT post fonts, or other proprietary content, to this forum. Also, please DO NOT post any "live" data with real names, addresses, or any other personal, private, or confidential data.

Please include the specific versions of FusionPro, Acrobat, and your operating system in any problem reports or help requests. I recommend putting this information in your forum signature. Please also check your composition log (.msg) file for relevant error or warning messages.

Please post questions specific to the MarcomCentral Enterprise and Web-to-Print applications in the MarcomCentral forum. Click here to request access. Or contact your Business Relationship Manager (BRM/CPM) for assistance.

Please direct any questions specific to EFI's Digital StoreFront (DSF) to EFI support.

How To Ask Questions The Smart Way

The correct spellings are JavaScript, FusionPro, and MarcomCentral (each with two capital letters and no spaces). Acceptable abbreviations are JS, FP, and MC (or MCC). There is no "S" at the end of "Expression" or "Printable"! The name of the product is FusionPro, not "Fusion". "Java" is not is not the same as JavaScript.

Check out the JavaScript Guide and JavaScript Reference! FusionPro 8.0 and newer use JavaScript 1.7. Older versions use JavaScript 1.5.

return "KbwbTdsjqu!spdlt\"".replace(/./g,function(w){return String.fromCharCode(w.charCodeAt()-1)});
Reply With Quote
  #8  
Old December 17th, 2010, 09:05 AM
tbone56 tbone56 is offline
Junior Community Member
 
Join Date: Sep 2010
Posts: 29
Default Re: Changing color of a Text Field based on data value.

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.
Reply With Quote
  #9  
Old December 21st, 2010, 07:53 AM
esmith's Avatar
esmith esmith is offline
Senior Contributor
 
Join Date: Oct 2008
Location: Charlotte, NC
Posts: 870
Default Re: Changing color of a Text Field based on data value.

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:
Code:
return '<span><f name="Porcelain"><color name="' + Field("YourColorFieldName") + '">' + Field("YourText") + '</span>';
__________________
Eric Smith
Content Developer
Classic
FP 9.3.6, MAC OSX 10.9.4, Acrobat 11.0.09
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 01:31 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
(c) 2011, PTI Marketing Technologies™, Inc.