pmorgan Posted March 4, 2009 Posted March 4, 2009 Good Afternoon, Is it possible to set the border of an image in a rule? I have a brochure and the user will be uploading an image which will size itself to best fit within the frame. The images being uploaded lack a border and need a border of black to appear around the image. My issue is that I can put the border around the frame, but this only works when the image is set to fill the frame, and I need the border to be dynamic with the image instead. Any thoughts?
pmorgan Posted March 4, 2009 Author Posted March 4, 2009 I'm adding a screenshot example. The image on the left is from the product, and you can see how the image is set to fill, and uses a border. Unfortunately the stretching of the image is an issue. The superimposed image is the original file, and ideally, the image in the product should maintain the proportions of the original, scale to fit the frame, and show a border around the picture (1 pt. thick, black). -Parrish Update: I have also tried the graphic inline rule shown here: return '<graphic resource="BioImage" width=6393.6 height=7156.8 scale=best alignv=center alignh=center>'; Can the border color be adjusted inside of this inline graphic rule? -P
Jeff Berry Posted September 7, 2011 Posted September 7, 2011 Hi Parrish, I know its been a couple years but do you remember if you figured this out? I am having a this exact problem. Thanks, Jeff
esmith Posted September 8, 2011 Posted September 8, 2011 To my knowledge, it is not possible to have FP add a border to a graphic that does not have the same dimensions as the frame it is placed within. The only thing I can think might work would be to place the image in a table cell and add a border programmatically to the cell, but I don't know for sure if this solution would work, or more importantly, be applicable to how you set up your template.
Jeff Berry Posted September 8, 2011 Posted September 8, 2011 The template that I'm working on is a postcard template which is filled with mostly variable text that is dropped in from the web. The picture is dropped in with this rule. //this adds the agent picture to the postcard if there is one available based on their agent number var Pic = new FusionProResource(Field("AgentNumber") + ".jpg", "graphic", true); if (Pic.exists) return Pic; ReportWarning("Image for " + Field("AgentNumber") + " not found"); There are roughly 500 different photos (agents) and I wouldn't guess that any of them will have the same dimensions as the graphic frame. Right now I have it set with 'Best Fit' and the clip setting selected. It works well. Ideally, we'd like to have a frame around the photo. However, as you said, there doesn't appear to be a way to add a frame within. I think I'm out of luck until I can convince our photographers to create a picture for each agent with the proper dimensions to accommodate the graphic frame. Thanks for you input. I appreciate it. Let me know if you ever run into a solution for it
Dan Korn Posted October 26, 2011 Posted October 26, 2011 From another thread: Can this be used to solve the problem in this thread? http://forums.pti.com/showthread.php?t=454&highlight=border+graphic Meaning, can you make a dynamic table cell that fits to an uploaded graphic then make a border around it? Yes, you could do something like this: function InlineGraphicWithBorder(res, color) { if (!res instanceof FusionProResource) throw "Not a resource: " + res; if (!res.exists) throw "Resource not found: " + res; var TM = new FusionProTextMeasure; TM.useTags = true; var err=TM.CalculateTextExtent(res.content); if (err) throw "Error measuring resource: " + res + ": " + TM.messages; var text = new FPTable; text.AddColumns(TM.textWidth); text.AddRows(1); text.Rows[0].Cells[0].Content = '<leading newsize=100>' + res.content; text.Rows[0].Cells[0].SetBorders("Thick", color, "Top", "Bottom", "Left", "Right"); text.Rows[0].Cells[0].Margins = new FPTableMargins; text.Rows[0].Cells[0].Margins.Top = 0; text.Rows[0].Cells[0].Margins.Bottom = 0; text.Rows[0].Cells[0].Margins.Left = 0; text.Rows[0].Cells[0].Margins.Right = 0; return text.MakeTags(); }
Jeff Berry Posted November 17, 2011 Posted November 17, 2011 Should this all be put into a graphic rule? I added your string and thought I edited it to apply to my pictures. It adds the photo but not within a table. var Pic = new FusionProResource(Field("Agent Number") + ".jpg", "graphic", true); if (Pic.exists) return Pic; ReportWarning("Image for " + Field("Agent Number") + " not found"); function InlineGraphicWithBorder(res, color) { if (!res instanceof FusionProResource) throw "Not a resource: " + Pic; if (!res.exists) throw "Resource not found: " + Pic; var TM = new FusionProTextMeasure; TM.useTags = true; var err=TM.CalculateTextExtent(Pic.content); if (err) throw "Error measuring resource: " + Pic + ": " + TM.messages; var text = new FPTable; text.AddColumns(TM.textWidth); text.AddRows(1); text.Rows[0].Cells[0].Content = '<leading newsize=100>' + Pic.content; text.Rows[0].Cells[0].SetBorders("Thick", color, "Top", "Bottom", "Left", "Right"); text.Rows[0].Cells[0].Margins = new FPTableMargins; text.Rows[0].Cells[0].Margins.Top = 0; text.Rows[0].Cells[0].Margins.Bottom = 0; text.Rows[0].Cells[0].Margins.Left = 0; text.Rows[0].Cells[0].Margins.Right = 0; return text.MakeTags(); } Did I do something wrong there?
esmith Posted November 17, 2011 Posted November 17, 2011 The function Dan posted appears to return tagged text with an embedded table and an inline graphic. In order to use his code, you would place his function (unedited) in the JavaScript Globals and then call it from a separate text rule. So instead of returning "Pic" in a graphic rule like you have above, you would have a text rule with the following: var Pic = new FusionProResource(Field("Agent Number") + ".jpg", "graphic", true); return InlineGraphicWithBorder(Pic, "Green"); //use your color pre-defined in Advanced/Colors... At least, that's how I think he intended it to be used.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.