Paul Cos Posted December 15, 2020 Posted December 15, 2020 I am looking to insert an “inline graphic” in front of a variable text field that would resize with the height of the text. Right now, I have a copyfitline rule that will resize the text based on the width of the box but the graphic doesn’t get smaller when the text does. I tried a regular CopyFit but it doesn’t resize the graphic either. The graphic is as big as the largest font size. Is there a way to measure the height of the text as it appears and apply it to the <graphic> tag? This is what I have so far. A RULE called CustomBrandingArea with this tag return '<graphic file="CustomBrandingArea.jpg">' I created a (field) called logo and place a logo as a Resources and called it logo2 and another RULE called TEST_RULE with this tag if (Field("logo2") != "") return '<magnify type=textwidth factor=100><z newsize=12.06>'+ Field("City") +Rule("CustomBrandingArea") + '</magnify>' ; else return "" Quote
Dan Korn Posted December 15, 2020 Posted December 15, 2020 (edited) A picture of what you're trying to accomplish would be worth a thousand words, and the collected job with the data would be better, so I have to do some guessing based on the limited information provided. But you should be able to use a variation of the CopyfitLineWithMagnifyTag function. Something like this should work, though I haven't tested it: var factor = 100; function CopyfitLineWithMagnifyTag(line, widthInPoints, AllowToExpand) { var tm = new FusionProTextMeasure; tm.CalculateTextExtent(line); if (tm.messages) ReportError("CopyfitMagnifyLine: " + tm.messages); if (tm.textWidth < widthInPoints*100 && !AllowToExpand) return line; factor = Round(widthInPoints / tm.textWidth * 10000, 0) - 1; return "<magnify type=pointsize factor=" + factor + ">" + line + "</magnify>"; } var frameWidth = 3 * 7200; // for rule validation, 3 inches var frame = FusionPro.Composition.CurrentFlow.GetFrame(); if (frame.GetSettableTextWidth) frameWidth = frame.GetSettableTextWidth(); // Put your font and initial size here: var font = "Arial"; var pointSize = 12; var text = '<graphic file="CustomBrandingArea.jpg" height=' + (pointSize * 100) + '><f name="' + font + '"><z newsize=' + pointSize + '>' + TaggedDataField("City"); var result = CopyfitLineWithMagnifyTag(text, frameWidth, true); return ReplaceSubstring(result, 'height=' + (pointSize * 100), 'height=' + (pointSize * factor)); Edited December 15, 2020 by Dan Korn Quote
Paul Cos Posted December 16, 2020 Author Posted December 16, 2020 Hi Dan, Yes you are absolutely correct about uploading the file, attached is the zip and image. Thank you for taking the time to assist me in this solution. I will try the rule that you supplied. -PaulExample.zip Quote
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.