blyons Posted October 15, 2019 Share Posted October 15, 2019 Greetings all, We are stumped on a copyfit issue, and would appreciate any help you may be able to give. Here is the rule and the issue below. thanks so much in advance for any help!!!! OnCopyfit Rule: Rule("OnCopyfit") if (FusionPro.Composition.CurrentFlow.name == "Event"); MagnifyAttributes("Event", 0, 400, 6, 0); if (FusionPro.Composition.CurrentFlow.name == "Special Message"); MagnifyAttributes("Special Message", 25, 400, 6, 72); ReportWarning("Could not copyfit text in flow " + FusionPro.Composition.CurrentFlow.name); In the Text frame “Event” under paragraph formatting, I have the box for “Do not break on copyfit” checked and under Overflow Options I have Adjust text to fit checked along with Allow text to expand to fill. So ideally, I would like whatever the customer types in to the box to fill the box and stay on one line However, right now it is breaking into two lines and discarding the text that doesn’t fit. screen shot attached Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted October 16, 2019 Share Posted October 16, 2019 Well, you're kind on the right track. The FusionPro User Guide has a section titled "Applying different copyfitting attributes to separate frames." Following the example there, you could do something like this: var magnifyAttrs = new MagnifyAttributes("text", 25, 400, 6, 72); // default magnification settings if (FusionPro.Composition.CurrentFlow.name == "Event") magnifyAttrs = new MagnifyAttributes("text", 0, 400, 6, 0); if (!Copyfit(magnifyAttrs)) ReportWarning("Could not copyfit text in flow " + FusionPro.Composition.CurrentFlow.name); Where you instantiate a new instance of an object of type MagnifyAttributes for each particular frame. (Note that the first parameter to the MagnifyAttributes constructor, as documented in the FusionPro Rules Guide, as well as in the Objects tab of the Building Blocks, is not a frame name, but rather a type, or method, of magnification, which can be one of: "text", "textheight", "textwidth", "leading", or "tracking", to control exactly how the text should be magnified [squeezed] to fit.) However, all that said, that's not going to work for the particular case you're in, which is basically what I would call single-line copyfitting, which is different from what that OnCopyfit rule controls, which is I call full-flow copyfitting. Instead of full-flow copyfitting for your single line, you want to use the CopyfitLine function, or better yet, my improved version of it, in a regular text rule, giving it the content (text) for the line, and then using that rule in the Text Editor. With recent versions of FusionPro, you can make this work in any text frame, without having to hard-code either the frame name or the width of the frame into the rule. You do still need to hard-code the initial font and point size though. It's hard to give you exactly the right rule without having the template, but something like this should work: var lineText = TaggedDataField("Event Name"); var initialFont = "Arial"; var initialPointSize = 30; if (FusionPro.inValidation) return lineText; var content = '<f name="' + initialFont + '"><z newsize="' + initialPointSize + '">' + lineText; var frameWidth = FusionPro.Composition.CurrentFlow.GetFrame().GetSettableTextWidth(); return CopyfitLineWithMagnifyTag(content, frameWidth); function CopyfitLineWithMagnifyTag(line, width, AllowToExpand) { var tm = new FusionProTextMeasure; tm.CalculateTextExtent(line); if (tm.messages) ReportError("CopyfitMagnifyLine: " + tm.messages); if (tm.textWidth < width && !AllowToExpand) return line; var factor = Round(width / tm.textWidth * 100, 0) - 1; return "<magnify type=text factor=" + factor + ">" + line + "</magnify>"; } Note that this goes into a regular old Text rule (NOT the OnCopyfitCallback), and you need to check both the "Re-evaluate this rule for every text flow" and "Treat returned strings as tagged text" boxes. The only other things you need to do are modify the first three lines of the rule to specify your data field and the initial font and size, then replace the variable calling out the data field in the Text Editor to call this rule instead. Quote Link to comment Share on other sites More sharing options...
blyons Posted October 16, 2019 Author Share Posted October 16, 2019 Thanks Dan, I replaced my rule with your suggested rule and when I validate it, it returns Expression Ok and the Return Value shows the correct message however the text box still breaks into two lines. Also, I might be missing something here but now when I compose the template I get an error message that reads: Composing record #1, input record 1 uncaught exception: TypeError: FusionPro.Composition.CurrentFlow.GetFrame is not a function uncaught exception: TypeError: FusionPro.Composition.CurrentFlow.GetFrame is not a function Job ended 09:13:54 - 1571231634. See Screen Shot Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted October 16, 2019 Share Posted October 16, 2019 Also, I might be missing something here but now when I compose the template I get an error message that reads:[/font][/color][/size] Composing record #1, input record 1 uncaught exception: TypeError: FusionPro.Composition.CurrentFlow.GetFrame is not a function uncaught exception: TypeError: FusionPro.Composition.CurrentFlow.GetFrame is not a function Okay, thanks for posting the picture with the log file. I can see that you're using FusionPro 10.0. This is why I ask you to please specify the versions of FusionPro, Acrobat, and your operating system, because the answer can be dependent on those, and I'm bad at guessing. In the absence of a specific version, my answers are always going to be for the latest version (currently FP 11), which is what I'm running. For FP 10.0, you can change line 9 of the rule to this: var frameWidth = FindTextFrame(FusionPro.Composition.CurrentFlow.name).GetSettableTextWidth(); Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted October 17, 2019 Share Posted October 17, 2019 Let me clarify that the FusionPro.Composition.CurrentFlow.GetFrame function is NOT new in FP 11. It was added in FusionPro 10.1. You don’t have it because you're running 10.0. You can upgrade for free to 10.1. Quote Link to comment Share on other sites More sharing options...
blyons Posted November 7, 2019 Author Share Posted November 7, 2019 Dan many thanks… That worked like a charm! My apologies for not seeing your recommendation regarding the inclusion of the FusionPro versioning. I will make a note of that and be sure to include my versioning on any future posts. 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.