Jump to content

Change Color In PDF Resource Rule


kjacobson

Recommended Posts

I am trying to get the new Change Color In PDF Resource Rule to work, but have been unsuccessful. I couldn't find instructions in the documentation, though I did see Dan's comment to jimmyharington on the new FP release thread (http://forums.pti.com/showthread.php?t=5390).

 

I've tried using the XML template as well as writing my own rule using <resource>.ChangeColor(string, string, number). I've tried using color names and color values. The only change I can manage to get to happen is when the color value to change is set to "All" the colors in the PDF change to 100% black.

 

What am I missing? Can someone provide me with a working example or let me know what values the XML template is expecting?

 

My test file is attached. Thanks!

ColorChangeTest-191223.zip

Link to comment
Share on other sites

The problem is that you're specifying color names such as Green and Blue for the replacement color.

 

Both the "Color value to change" and the "Field or rule for the new color" parameters expect an RGB or CMYK value, either as six or eight hex digits (such as "FF0000" for RGB Red or "FF000000" for CMYK Cyan), or as delimited strings of decimal percentages (such as "100,0,0" for RGB Red or "100,0,0,0" for CMYK Cyan).

 

The idea behind this is that arbitrary data will not rely on and be limited to the named colors in the FusionPro template, but will instead provide numeric RGB or CMYK values.

 

I got this to work to change the RGB Red to RGB Green:

Pic.ChangeColor("FF0000", "00FF00", 10);

And this to change RGB Red to CMYK Magenta:

Pic.ChangeColor("FF0000", "00FF0000", 10); 

 

I suppose that both the XML Template rule and the JavaScript function could be either more forgiving and accept named colors, or more explicit about not accepting them.

Link to comment
Share on other sites

Thank you Dan. That was the information I needed to get this working. Yes, being able to use color names would be helpful. Thanks again!

I entered an enhancement request for that: FP-305.

 

In the meantime, I was able to get named colors working like so:

var Pic = CreateResource(Field("File"));
var color = Color(Field("Color"));
var colorVals = [color.cyan, color.magenta, color.yellow, color.black];
Pic.ChangeColor("FF0000", colorVals, 10); 
return Pic;

Edited by Dan Korn
Link to comment
Share on other sites

Thanks for the help Dan.

 

I've gotten this to work great in a graphic frame, but can this also be used with inline graphics?

 

I've tried

var mapPointer = CreateResource("MapPointer.pdf", "graphic", true);
mapPointer.ChangeColor("All","85,0,54,52",10);

return mapPointer.content;

Which returns:

<graphic file="MapPointer.pdf" hascolorchanges="true"><colorchange fromcolor="All" tocolor="85,0,54,52" tolerance="10" /></graphic>

But the graphic does not change color.

Link to comment
Share on other sites

I've gotten this to work great in a graphic frame, but can this also be used with inline graphics?

No, it cannot currently be used with inline graphics.

 

You could create a repeatable component with a graphic frame, insert the PDF into that, then insert the repeatable component into your text.

Link to comment
Share on other sites

Thanks for the work around Dan. Unfortunately, I am trying to use this in a table where the width of the cell changes based on the width of a logo. It's my understanding that repeatable components do not work in tables.

 

Perhaps I will try the same concept, but with text and graphic frames instead.

Link to comment
Share on other sites

  • 2 weeks later...

I've been working with the ChangeColorInPDFBackground function. I've been able to change blocks of color in the background, but it doesn't change outlines or colored text. Is this expected functionality? It also didn't change a gradient, but I figured that would be a long shot.

 

Code used in OnRecordStart:

FusionPro.Composition.ChangeColorInPDFBackground("All", "0,100,0,0", "10");

Image of result attached.

FG-ChangeColorInPDFBackground-200109.thumb.jpg.68129851531dd7b12afee5cd15e08c94.jpg

Link to comment
Share on other sites

I've been working with the ChangeColorInPDFBackground function. I've been able to change blocks of color in the background, but it doesn't change outlines or colored text. Is this expected functionality? It also didn't change a gradient, but I figured that would be a long shot.

The "change color in PDF" feature works only for shapes in the PDF, in process colors. It does not work for text, or gradients, or graphic objects, nor does it work for spot colors.

 

It's possible that if you go into Illustrator or some other app and convert the text in the PDF to outlines, that the color of those could be changed, but I haven't tried that.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...