Jump to content

Assigning color in OnRecordStart


jdubois

Recommended Posts

I have a product which references defined colors in the PDF document for various colored text and text boxes, etc. As example, color 1 is C=4 M=24 Y=50 K=25, color 2 is C=25 M=25 Y=0 K=0, etc. I have defined these colors in the fusion pro document under Advanced>Colors menu.

 

now the user would like to be able to change these colors within the fields of the Marcomm store. So for example, out of a list of 12 defined colors for the product, they would like to select and define from a drop down for color 1, color 2, color 3, etc. and have it utilize those values to create the PDF.

 

I have no idea how to define color values on the fly rather than through the fusion pro program, though I am assuming it can be done in some fashion with an OnRecordStart rule.

 

Can anyone help me with an example on how I might be able to accomplish this?

Link to comment
Share on other sites

I don't know that that can be done with JavaScript within a FP rule. I would think you would need to define all your colors in the Color palette and then offer a drop down box on MarcomCentral for the user to choose the colors they want from your existing palette.

 

Having said that, I just recently learned that it is possible to write a custom XML .dif file during the call from the portal to FPServer. Since the .dif file contains the color definitions, it stands to reason that colors could be defined via custom-generated .difs for each "order". Since I am just now "stepping in the shallow end" of this concept, you will need Dan's assistance (as will I).

Link to comment
Share on other sites

You can do this with the <color> tag. The only issue is it is expecting hex values. I wrote the following function to convert CMYK to hex:

 

function cmyk2hex(cmyk)
{
   a = cmyk.split("-");
   hex = "";

   for (x=0;x<4;x++)
   {
       h = Math.round(a[x] * 2.55).toString(16);
       if (h.length == 1) hex += "0" + h;
       else hex += h;
   }

   return hex;
}

return '<color cmyk="' + cmyk2hex("100-0-40-0") + '">' + "text" + '</color>';

 

Just put your values in CMYK order between the hyphens.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...