dml1280 Posted July 21, 2022 Share Posted July 21, 2022 Is there a color change rule to change the color of an inline graphic? Or it only works on a pdf brought in with a graphic box? This is the code I am using for the inline graphic... // Rule converted from XML Template "Inline Graphic Rule: Community Name": // Begin XML Template selections // var FieldName = "Social Media Icons"; // "Choose the field containing the graphic name:" (Required): FieldList var Format = "pdf"; // "Choose the type of graphic:" (Required): PickList ["jpg" (JPG or JPEG), "tif" (TIF or TIFF), "png" (PNG), "pdf" (PDF), "gif" (GIF), "eps" (EPS)] var SearchPath = ""; // "Enter a search path:": FolderPath var DefaultGraphic = "Social Media - White .1875"; // "Choose a default graphic:": ResourceList (Graphic) var SkipIfNoValue = false; // "Skip if the field value is empty": CheckBox var Width = HundredthsOfPointsFromText("0 in"); // "Override graphic width (zero to use existing width):": Space var Height = HundredthsOfPointsFromText(".16 in"); // "Override graphic height (zero to use existing height):": Space // End XML Template selections // var fieldVal = Field(FieldName); if (!fieldVal && SkipIfNoValue) return ""; var path = CombinePath(SearchPath, fieldVal); var Pic = NullResource(); for (var pass = 1; ; pass++) { switch (pass) { case 1: var validExtensions = [".png", ".pdf", ".gif", ".eps", ".tif", ".tiff", ".jpg", ".jpeg"]; if (validExtensions.indexOf(GetFileExtension(path).toLowerCase()) >= 0) Pic = CreateResource(path, "graphic", true); break; case 2: Pic = CreateResource(ReplaceFileExtension(path, Format.toLowerCase()), "graphic", true); break; case 3: var altExtensions = { JPG: "jpeg", TIF: "tiff" }; Pic = CreateResource(ReplaceFileExtension(path, altExtensions[Format.toUpperCase()]), "graphic", true); break; case 4: //Print("Graphic not found: " + fieldVal); if (!DefaultGraphic) return ""; //else Pic = Resource(DefaultGraphic); default: return ""; // should never get here } Pic.width = Width; Pic.height = Height; if (Pic.exists) return Pic; } return ""; // should never get here Thanks. Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted July 21, 2022 Share Posted July 21, 2022 You can change the color of a resource, and use it inline, but it works only for PDF resources, not for any other graphic format. If it's a PDF, you can just add a line like so before you return the resource: // Change all colors to Blue. Pic.ChangeColor("ALL", "0,0,255", 10); Quote Link to comment Share on other sites More sharing options...
dml1280 Posted July 21, 2022 Author Share Posted July 21, 2022 I added it here } Pic.width = Width; Pic.height = Height; Pic.ChangeColor("ALL", "0, 0, 0, 60", 10); // Change all colors. if (Pic.exists) return Pic; But it had no effect. Also, is there a way to add a little padding above the inline image so it lines up better with the text? Thank you so much for your help. Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted July 21, 2022 Share Posted July 21, 2022 I added it here } Pic.width = Width; Pic.height = Height; Pic.ChangeColor("ALL", "0, 0, 0, 60", 10); // Change all colors. if (Pic.exists) return Pic; But it had no effect. Well, it's hard to know what you're expecting, let alone why that's not the result you're getting, without more information, especially without the files. Note that this doesn't necessarily work with every PDF; it depends on how the objects are shown in the PDF file. If the PDF is merely a wrapper for a raster image, it's probably not going to work. If it's vector art, that's more likely to work. I would try just using the default "Change Color In PDF Resource Rule" Form Rule and see if that works. If you want to attach the graphic here, I can take a look at it. Also, is there a way to add a little padding above the inline image so it lines up better with the text? There are a few things you can do. You could subscript the inline graphic. You could adjust the height of the graphic. Depending on how you're trying to lay things out, you could just make this a separate frame, not inline at all. You could also use a table, and set margins separately for cells for the graphic and the other text. That's just a few of many possibilities. Thank you so much for your help. Sure! Thanks for an interesting question. 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.