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.
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
Code:
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.