Go Back   MarcomCentral (PTI) and FusionPro User Communities > Software-Related Talk > The JavaScript Library > Formatting Text

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #11  
Old April 16th, 2015, 01:00 PM
DSweet's Avatar
DSweet DSweet is offline
Senior Contributor
 
Join Date: Sep 2008
Location: Oberlin, Ohio
Posts: 240
Default Re: Applying a Specific Color to a Variable

I'd like to chime in on this with an additional twist to the problem...we are doing items for different area schools and would like to have type and backgrounds output in their specific school color. We are being supplied with either a PMS color or a cmyk build-up for their color. Either way we have the ability to get the base cmyk build for each school. My problem is that if we do 100 schools, I would probably need to individually program around 60 or maybe 70 specific colors for the different schools, then create a rule to change the color to one of this variations. I would like to stream-line that down to just one definition.

Is there a way to have a predefined color name, in my example say "schoolColor", and then within the data file dynamically read in the color values and assign it to schoolColor. So for records 1 thru 10 every variable item in the template that is defined with "schoolColor" would turn a specific color of Blue for School-A, then when records 11 thru 25 are read in the definition of "schoolColor" is reassigned to a cmyk variation of Red or Green or Pink or whatever school is being processed at the time.

Having to predefine and program less than 100 schools and colors might not be too bad, but if this program takes off we might be doing 1000's of schools with virtually any number of school colors. That's a headache that I don't want to be hit with.

Any help would be appreciated.
.
__________________
David A. Sweet
Variable Data Specialist
HKM Direct Market Communications
Windows 7, Acrobat 10.x
FusionPro Desktop and Server 10.0.26
Reply With Quote
  #12  
Old April 16th, 2015, 01:25 PM
step's Avatar
step step is offline
Senior Contributor
 
Join Date: Jan 2010
Location: Charlotte, NC
Posts: 955
Default Re: Applying a Specific Color to a Variable

I would think you could put something like this in your OnRecordStart rule to define the CMYK values of the color you've defined in your template:
Code:
var field = "100,0,100,0"; // Your CMYK Field
var [c,m,y,k] = field.split(',').map(function(s){ s=StringToNumber(s); return (s>100) ? 100 : (s < 0) ? 0 : s;})
new FusionProColor("schoolColor", c, m, y, k);
I'm assuming that the field you're keying off of is a comma-separated CMYK definition but I'm sure you could easily adapt this solution to your particular scenario.
__________________
Ste Pennell
FusionPro VDP Creator 9.3.15
Adobe Acrobat X 10.1.1
Mac OS X 10.12

LinkedIn
Reply With Quote
  #13  
Old April 16th, 2015, 02:34 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,369
Default Re: Applying a Specific Color to a Variable

Quote:
Originally Posted by DSweet View Post
I'd like to chime in on this with an additional twist to the problem...we are doing items for different area schools and would like to have type and backgrounds output in their specific school color. We are being supplied with either a PMS color or a cmyk build-up for their color. Either way we have the ability to get the base cmyk build for each school. My problem is that if we do 100 schools, I would probably need to individually program around 60 or maybe 70 specific colors for the different schools, then create a rule to change the color to one of this variations. I would like to stream-line that down to just one definition.

Is there a way to have a predefined color name, in my example say "schoolColor", and then within the data file dynamically read in the color values and assign it to schoolColor. So for records 1 thru 10 every variable item in the template that is defined with "schoolColor" would turn a specific color of Blue for School-A, then when records 11 thru 25 are read in the definition of "schoolColor" is reassigned to a cmyk variation of Red or Green or Pink or whatever school is being processed at the time.

Having to predefine and program less than 100 schools and colors might not be too bad, but if this program takes off we might be doing 1000's of schools with virtually any number of school colors. That's a headache that I don't want to be hit with..
Sure, this is possible. Although exactly what to do depends on what you're trying to apply a color to; in other words, it's different for text than for things like frame borders and fill/shading.

For text, it's pretty easy: you just use <color> tags. As detailed in the FusionPro Tags Reference Guide (and elsewhere in these forums), you can specify either RGB or CMYK attributes, with hexadecimal values, such as <color rgb="ff0000"> or <color cmyk="ff00ff00">, in addition to being able to call out a color by name, such as <color name="green">.

You can also add a named color in JavaScript, with the FusionPro Color object, as detailed here:
http://forums.pti.com/showpost.php?p=11580&postcount=3

In OnRecordStart, you can add a new color on a per-record basis by calling "new FusionProColor", or modify an existing color by calling the Color function or accessing a property of FusionPro.Colors to obtain a FusionProColor object, which you can then modify. You can also add a new color "on the fly" in any rule where you need it. Then you can access that color, by name, in a <color> tag in text, and also for things like frame borders and fills, with properties like borderColorName or fillColorName on a frame object returned from FindTextFrame or FindGraphicFrame.

Or you can simply modify an existing color in OnRecordStart, and the changes will apply to everything using that named color in the record, which is basically what Step's code does. Or you could do it like this:
Code:
var color = Color("schoolColor");
color.cyan = 20;
color.magenta = 50;
color.yellow = 30;
color.black = 0;
Or the same thing with this as the first line instead of the call to the Color function:
Code:
var color = FusionPro.Colors["schoolColor"];
As in the other post, with the JavaScript objects, each color range is a decimal percentage, from 0 to 100.

If you want to call out a Spot color, such as Pantone color, you can set the .isSpot property of the FusionProColor object to true, or pass true as the sixth parameter in the call to "new FusionProColor". Then you can call that color out by name, either in a <color> tag, or by setting a property in JavaScript to it, just like with any other color, and as long as that spot color is indeed available when the output is printed, it should work. Although you should try to get the CMYK process color equivalent of the spot color right for on-screen display or other conversions.
__________________
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
  #14  
Old April 16th, 2015, 03:09 PM
DSweet's Avatar
DSweet DSweet is offline
Senior Contributor
 
Join Date: Sep 2008
Location: Oberlin, Ohio
Posts: 240
Default Re: Applying a Specific Color to a Variable

So I am restricted into only being able to do this by a color-tag? I am not able to predefine in the Colors Palette the color "schoolColor" and then redefine it in OnRecordStart? This way I would be able to just use the color as part of the pull downs when assigning it to text and frame elements?
__________________
David A. Sweet
Variable Data Specialist
HKM Direct Market Communications
Windows 7, Acrobat 10.x
FusionPro Desktop and Server 10.0.26
Reply With Quote
  #15  
Old April 16th, 2015, 03:18 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,369
Default Re: Applying a Specific Color to a Variable

Quote:
Originally Posted by DSweet View Post
So I am restricted into only being able to do this by a color-tag?
No, you're not restricted that way at all. Sorry if I wasn't clear in my post:
Quote:
Originally Posted by Dan Korn View Post
Or you can simply modify an existing color in OnRecordStart, and the changes will apply to everything using that named color in the record, which is basically what Step's code does. Or you could do it like this...
Quote:
Originally Posted by DSweet View Post
I am not able to predefine in the Colors Palette the color "schoolColor" and then redefine it in OnRecordStart?
Yes, you can in fact do exactly that. Here's a better example: If I set some text in Red, and then add this line to OnRecordStart:
Code:
new FusionProColor("Red", 100, 0, 0, 0);
It then comes out in Cyan (light blue) in the output.
Quote:
Originally Posted by DSweet View Post
This way I would be able to just use the color as part of the pull downs when assigning it to text and frame elements?
Yes.
__________________
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
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 07:02 AM.


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