DynaPDF.GetFTextHeight
----------------------

The function measures the height of a formatted text block.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [DynaPDF](component_DynaPDF.md) | [3.1](newinversion31.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "DynaPDF.GetFTextHeight"; PDF; Align; Text ) 

**MBS**( **"DynaPDF.GetFTextHeight";** /\* The function measures the height of a formatted text block. \*/  
**$PDF**; /\* The PDF reference returned from [DynaPDF.New](DynaPDFNew.md). \*/   
**$Align**; /\* The text alignment. Can be left, center, right or justify.e.g. "left" \*/   
**$Text**) /\* The text to write.e.g. "Hello World" \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| PDF | The PDF reference returned from [DynaPDF.New](DynaPDFNew.md). | $pdf |
| 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.   
Before calling this function a font (see [DynaPDF.SetFont](DynaPDFSetFont.md)) and the output rectangle must be set with the function [DynaPDF.SetTextRect](DynaPDFSetTextRect.md). The parameter Height of [DynaPDF.SetTextRect](DynaPDFSetTextRect.md) should be set to -1 to avoid page breaks. Otherwise the height of the first text block is returned that fits into the given height of the rectangle.  
The parameter AText must contain the same text (incl. format tags if any) as which should be printed later with [DynaPDF.WriteFText](DynaPDFWriteFText.md).  
  
See also [DynaPDF.GetFTextHeightEx](DynaPDFGetFTextHeightEx.md).  
See also [GetFTextHeight](https://www.monkeybreadsoftware.com/DynaPDF-Manual/GetFTextHeight.shtml) function in DynaPDF manual.

### Examples

Place text centered on page:

 # top down coordinates   
Set Variable \[ $r ; Value: MBS ("[DynaPDF.SetPageCoords](DynaPDFSetPageCoords.md)"; $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](DynaPDFConvertStyledText.md)"; $pdf ; $FileMakerText ) \]   
\# measure   
Set Variable \[ $Width ; Value: 400 \]   
Set Variable \[ $Height ; Value: MBS ( "DynaPDF.GetFTextHeight"; $PDF ; "left"; $FText ) \]   
\# lookup page size   
Set Variable \[ $PageWidth ; Value: MBS ( "[DynaPDF.GetPageWidth](DynaPDFGetPageWidth.md)"; $PDF ) \]   
Set Variable \[ $PageHeight ; Value: MBS ( "[DynaPDF.GetPageHeight](DynaPDFGetPageHeight.md)"; $PDF ) \]   
\# now center text on page   
Set Variable \[ $r ; Value: MBS ("[DynaPDF.SetTextRect](DynaPDFSetTextRect.md)"; $pdf ; ($PageWidth - $Width ) / 2; ($PageHeight - $Height ) / 2; $Width ; $Height ) \]   
Set Variable \[ $r ; Value: MBS ("[DynaPDF.WriteFText](DynaPDFWriteFText.md)"; $pdf ; "left"; $FText ) \]  
### See also

- [DynaPDF.GetFTextHeightEx](DynaPDFGetFTextHeightEx.md)
- [DynaPDF.GetPageHeight](DynaPDFGetPageHeight.md)
- [DynaPDF.GetTemplHeight](DynaPDFGetTemplHeight.md)
- [DynaPDF.GetTextWidth](DynaPDFGetTextWidth.md)
- [DynaPDF.SetFont](DynaPDFSetFont.md)
- [DynaPDF.SetFontWeight](DynaPDFSetFontWeight.md)
- [DynaPDF.SetPageHeight](DynaPDFSetPageHeight.md)
- [DynaPDF.SetTextRect](DynaPDFSetTextRect.md)
- [DynaPDF.WriteFText](DynaPDFWriteFText.md)
- [DynaPDF.WriteStyledTextEx](DynaPDFWriteStyledTextEx.md)

This function checks for a license.

Created 18th August 2014 , last changed 3th January 2021

  
[DynaPDF.GetEmbeddedFilesAsJSON](DynaPDFGetEmbeddedFilesAsJSON.md) - [DynaPDF.GetFTextHeightEx](DynaPDFGetFTextHeightEx.md)

[HTML Version](DynaPDFGetFTextHeight.shtml)