Components | All | New | MacOS | Windows | Linux | iOS | ||||
Examples | Mac & Win | Server | Client | Guides | Statistic | FMM | Blog | Deprecated | Old |
DynaPDF.GetFTextHeightEx
The function measures the height of a formatted text block.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
DynaPDF | 3.1 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
Parameters
Parameter | Description | Example |
---|---|---|
The PDF reference returned from DynaPDF.New. | ||
Width | Width of output rectangle | $width |
Align | The text alignment. Can be left, center, right or justify. | "left" |
Text | The text to write. | "Hello World" |
Result
Returns height or error message.
Description
The function measures the height of a formatted text block.The function works in the same way as DynaPDF.GetFTextHeight but the output rectangle must not be set manually beforehand.
The height of the output rectangle is set to -1 to avoid a page break during measuring.
The parameter text must contain the same text (incl. format tags if any) as which should be printed
later with DynaPDF.GetFTextHeightEx.
See also DynaPDF.GetFTextHeight.
See also GetFTextHeightEx function in DynaPDF manual.
Examples
Place text centered on page:
# top down coordinates
Set Variable [ $r ; Value: MBS("DynaPDF.SetPageCoords"; $pdf; "TopDown") ]
# get the styled text to place
Set Variable [ $FileMakerText ; Value: Create Text::Text ]
# convert to Formatted Text for DynaPDF
Set Variable [ $FText ; Value: MBS( "DynaPDF.ConvertStyledText"; $pdf; $FileMakerText ) ]
# measure
Set Variable [ $Width ; Value: 400 ]
Set Variable [ $Height ; Value: MBS( "DynaPDF.GetFTextHeightEx"; $PDF; $Width; "left"; $FText ) ]
# lookup page size
Set Variable [ $PageWidth ; Value: MBS( "DynaPDF.GetPageWidth"; $PDF ) ]
Set Variable [ $PageHeight ; Value: MBS( "DynaPDF.GetPageHeight"; $PDF ) ]
# now center text on page
Set Variable [ $r ; Value: MBS("DynaPDF.SetTextRect"; $pdf; ($PageWidth - $Width) / 2; ($PageHeight - $Height) / 2; $Width; $Height) ]
Set Variable [ $r ; Value: MBS("DynaPDF.WriteFText"; $pdf; "left"; $FText) ]
Measure text height and draw it aligned to bottom of page:
# get some styled text from FileMaker
Set Variable [ $StyledText ; Value: MyTable::MyText ]
If [ Length ( $StyledText ) > 0 ]
# Convert to the styles DynaPDF needs
Set Variable [ $text ; Value: MBS( "DynaPDF.ConvertStyledText"; $PDF; $StyledText; $LeadingFactor ) ]
# set a default font and color
Set Variable [ $r ; Value: MBS("DynaPDF.SetFont"; $pdf; "Helvetica"; 0; 12) ]
Set Variable [ $r ; Value: MBS("DynaPDF.SetFillColor"; $pdf; 0; 0; 0) ]
# calculate height for this block
Set Variable [ $height ; Value: MBS( "DynaPDF.GetFTextHeightEx"; $PDF; 240; "left"; $Text ) ]
# Set the area where the text is output based on height from bottom of page
Set Variable [ $r ; Value: MBS("DynaPDF.SetTextRect"; $pdf; 620; 28 + $height + $PositionOffset; 240; $height + 5) ]
# and draw it
Set Variable [ $r ; Value: MBS("DynaPDF.WriteFText"; $pdf; "left"; $text) ]
End If
See also
- DynaPDF.ConvertStyledText
- DynaPDF.GetFontWeight
- DynaPDF.GetFTextHeight
- DynaPDF.GetTemplHeight
- DynaPDF.New
- DynaPDF.SetFont
- DynaPDF.SetTextRect
- DynaPDF.WriteFText
- DynaPDF.WriteStyledText
- DynaPDF.WriteStyledTextEx
This function checks for a license.
Created 18th August 2014, last changed 27th May 2021