DynaPDF.WriteStyledTextEx
-------------------------

Writes styled text on current page.

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

MBS( "DynaPDF.WriteStyledTextEx"; PDF; PosX; PosY; Width; Height; Align; Text { ; LeadingFactor } ) 

**MBS**( **"DynaPDF.WriteStyledTextEx";** /\* Writes styled text on current page. \*/  
**$PDF**; /\* The PDF reference returned from [DynaPDF.New](DynaPDFNew.md). \*/   
**$PosX**; /\* X-Coordinate of output rectanglee.g. $x \*/   
**$PosY**; /\* Y-Coordinate of output rectanglee.g. $y \*/   
**$Width**; /\* Width of output rectanglee.g. $w \*/   
**$Height**; /\* Height of output rectangle or -1.e.g. $h \*/   
**$Align**; /\* The text alignment. Can be left, center, right or justify.e.g. "left" \*/   
**$Text**; /\* The text to write.e.g. "Hello World" \*/   
**$LeadingFactor**) /\* Optional; If you pass a value &gt; 0, the plugin will add \\LD\[\] commands to styled text to set leading relative to font size. This way you define the spacing beteween lines.e.g. 1.2 \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| PDF | The PDF reference returned from [DynaPDF.New](DynaPDFNew.md). | $pdf |  |
| PosX | X-Coordinate of output rectangle | $x |  |
| PosY | Y-Coordinate of output rectangle | $y |  |
| Width | Width of output rectangle | $w |  |
| Height | Height of output rectangle or -1. | $h |  |
| Align | The text alignment. Can be left, center, right or justify. | "left" |  |
| Text | The text to write. | "Hello World" |  |
| LeadingFactor | If you pass a value &gt; 0, the plugin will add \\LD\[\] commands to styled text to set leading relative to font size. This way you define the spacing beteween lines. | 1.2 | Optional      Added in version **11.0**. |

### Result

Returns OK or error.

### Description

Writes styled text on current page.  
Converts for you the styled text to the formatted text commands from DynaPDF.  
Use [DynaPDF.GetFTextHeightEx](DynaPDFGetFTextHeightEx.md) or [DynaPDF.GetFTextHeight](DynaPDFGetFTextHeight.md) to calculate the space needed for the text if you want to create a matching text rectangle for vertical alignment.  
  
See [DynaPDF.AllowPageBreak](DynaPDFAllowPageBreak.md) for whether to do page breaks or not.  
  
Please set a font first with [DynaPDF.SetFont](DynaPDFSetFont.md) function before you write on the page. As this function uses font settings from FileMaker field, it may ignore whatever font or style you loaded before.  
  
Internally calls [DynaPDF.ConvertStyledText](DynaPDFConvertStyledText.md) and [DynaPDF.WriteFTextEx](DynaPDFWriteFTextEx.md).  
  
MBS Plugin in version 11.5 with DynaPDF 4.0.62.160 adds support for double underlined text.  
See also [WriteStyledTextEx](https://www.monkeybreadsoftware.com/DynaPDF-Manual/WriteFTextEx.shtml) function in DynaPDF manual.

### Examples

Write styled text with rectangle:

 # page size   
Set Variable \[ $pw ; Value: MBS ("[DynaPDF.GetPageWidth](DynaPDFGetPageWidth.md)"; $pdf ) \]   
Set Variable \[ $ph ; Value: MBS ("[DynaPDF.GetPageHeight](DynaPDFGetPageHeight.md)"; $pdf ) \]   
\# set black color   
Set Variable \[ $r ; Value: MBS ("[DynaPDF.SetFillColor](DynaPDFSetFillColor.md)"; $pdf ; 0; 0; 0) \]   
\# write styled text   
Set Variable \[ $r ; Value: MBS ("DynaPDF.WriteStyledTextEx"; $pdf ; 100; $ph -100; $pw -200; $ph -200; "left"; Create Text::Text ) \]  
### See also

- [DynaPDF.AllowPageBreak](DynaPDFAllowPageBreak.md)
- [DynaPDF.GetFTextHeight](DynaPDFGetFTextHeight.md)
- [DynaPDF.GetFTextHeightEx](DynaPDFGetFTextHeightEx.md)
- [DynaPDF.GetPageWidth](DynaPDFGetPageWidth.md)
- [DynaPDF.New](DynaPDFNew.md)
- [DynaPDF.SetFillColor](DynaPDFSetFillColor.md)
- [DynaPDF.SetFont](DynaPDFSetFont.md)
- [DynaPDF.WriteFTextExRotated](DynaPDFWriteFTextExRotated.md)
- [DynaPDF.WriteStyledText](DynaPDFWriteStyledText.md)
- [DynaPDF.WriteStyledTextExRotated](DynaPDFWriteStyledTextExRotated.md)

### Release notes

- **Version 13.2**
    - Added new highlight style for [DynaPDF.ConvertStyledText](https://www.mbsplugins.eu/DynaPDFConvertStyledText.shtml), [DynaPDF.WriteStyledText](https://www.mbsplugins.eu/DynaPDFWriteStyledText.shtml) and [DynaPDF.WriteStyledTextEx](https://www.mbsplugins.eu/DynaPDFWriteStyledTextEx.shtml).
- **Version 11.0**
    - Added leading factor parameter for [DynaPDF.ConvertStyledText](https://www.mbsplugins.eu/DynaPDFConvertStyledText.shtml), [DynaPDF.WriteStyledText](https://www.mbsplugins.eu/DynaPDFWriteStyledText.shtml) and [DynaPDF.WriteStyledTextEx](https://www.mbsplugins.eu/DynaPDFWriteStyledTextEx.shtml).
- **Version 7.4**
    - Added [DynaPDF.WriteFTextExRotated](http://www.mbsplugins.eu/DynaPDFWriteFTextExRotated.shtml) and [DynaPDF.WriteStyledTextExRotated](http://www.mbsplugins.eu/DynaPDFWriteStyledTextExRotated.shtml).

### Example Databases

- [DynaPDF/Create Text as PDFA](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/DynaPDF/Create%20Text%20as%20PDFA.shtml#6ScriptAnchor_)

### Blog Entries

- [Using DynaPDF with Data API for PDF generation](https://www.mbsplugins.de/archive/2026-05-25/Using_DynaPDF_with_Data_API_fo/monkeybreadsoftware_blog_filemaker)
- [Draw images with text using DynaPDF](https://www.mbsplugins.de/archive/2026-01-03/Draw_images_with_text_using_Dy/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 13.2pr4](https://www.mbsplugins.de/archive/2023-04-25/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [Things you can do with DynaPDF](https://www.mbsplugins.de/archive/2021-07-02/Things_you_can_do_with_DynaPDF/monkeybreadsoftware_blog_filemaker)
- [New in MBS FileMaker Plugin 11.0](https://www.mbsplugins.de/archive/2021-01-26/New_in_MBS_FileMaker_Plugin_11/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 11.0pr6](https://www.mbsplugins.de/archive/2021-01-09/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 6.5pr3](https://www.mbsplugins.de/archive/2016-10-18/MBS_FileMaker_Plugin_version_6/monkeybreadsoftware_blog_filemaker)

### FileMaker Magazin

- [Ausgabe 5/2021, Seite 28](https://filemaker-magazin.de/neuigkeit/4158-Appetithappen-FMM_202105)

This function checks for a license.

Created 13th October 2016 , last changed 30th October 2021

  
[DynaPDF.WriteStyledText](DynaPDFWriteStyledText.md) - [DynaPDF.WriteStyledTextExRotated](DynaPDFWriteStyledTextExRotated.md)

[HTML Version](DynaPDFWriteStyledTextEx.shtml)