Joshua_F Posted November 19, 2020 Share Posted November 19, 2020 We have been using the method below for years to determine whether a piece is landscape or portrait for some handouts. Testing out FP11 and so far this is the only thing that I've noticed that is causing issues with our code. var item = CreateResource(path("_graphics") + itemNumberFD,'graphic',true); // Determine if the item graphic is landscape or portrait formatFD = GetOrientation(item,localOrientation); function GetOrientation(res, fallback){ // Text Measure doesn't run in validation so set a fall back // orientation to return in local dev. If the param is null // return 'portrait' orientation var fallback = fallback || "portrait"; try{ 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; Print(res + ": Width=" + TM.textWidth + ", Depth=" + TM.textHeight); var isLandscape = (TM.textWidth > TM.textHeight); return (isLandscape) ? "landscape" : "portrait"; } catch(e){ return fallback; } } In the logs on composition, we're getting The amount of text inserted into a flow exceeds the depth of all frames in the flow <>. Text is truncated. Text does not fit in the last frame on page 0 at (0 in, 0 in). Resource("../_graphics/BFH-059.pdf"): Width=81000, Depth=0 Running FusionPro VDP Server 11.2.1 on a Mac OS 10.13.6 High Sierra. I've tried passing strings through that FusionProTextMeasure constructor and still get a textHeight property of 0. Quote Link to comment Share on other sites More sharing options...
BloodGageAlex Posted June 15, 2021 Share Posted June 15, 2021 Did you find a solution to your issue? Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted June 16, 2021 Share Posted June 16, 2021 (edited) In FP 11 and later on Mac specifically, text measurement of graphics fails at rule validation time, i.e. when you're in the Rule Editor and click validate. However, as far as I know (and I just tried it to verify), it does work properly at composition time. So if you return the textHeight property and put the rule into a text frame, the correct value should appear in the output. Or, if you put it into a Print() function call, the correct value should be written to the composition log (.msg) file. And any usage of the function to determine whether the graphic is landscape or portrait should still work in composition. Sorry for the trouble here. Edited June 16, 2021 by Dan Korn Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted June 16, 2021 Share Posted June 16, 2021 Also, you can get it to work at rule validation time by providing the full path to the graphic, which can be obtained with the FusionPro.ResolveFile function. So it will work at validation time if you add that call in the first line, like so: var item = CreateResource(FusionPro.ResolveFile(path("_graphics") + itemNumberFD), 'graphic', true); 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.