kjacobson Posted December 23, 2019 Share Posted December 23, 2019 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 Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted December 24, 2019 Share Posted December 24, 2019 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. Quote Link to comment Share on other sites More sharing options...
kjacobson Posted December 26, 2019 Author Share Posted December 26, 2019 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! Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted December 26, 2019 Share Posted December 26, 2019 (edited) 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 December 26, 2019 by Dan Korn Quote Link to comment Share on other sites More sharing options...
kjacobson Posted December 29, 2019 Author Share Posted December 29, 2019 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. Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted December 30, 2019 Share Posted December 30, 2019 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. Quote Link to comment Share on other sites More sharing options...
kjacobson Posted December 30, 2019 Author Share Posted December 30, 2019 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. Quote Link to comment Share on other sites More sharing options...
kjacobson Posted January 10, 2020 Author Share Posted January 10, 2020 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. Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted January 10, 2020 Share Posted January 10, 2020 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.