DynaPDF.WriteStyledText
-----------------------

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.WriteStyledText"; PDF; Align; Text { ; LeadingFactor } ) 

**MBS**( **"DynaPDF.WriteStyledText";** /\* Writes styled text on current page. \*/  
**$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" \*/   
**$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 |  |
| 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.WriteFText](DynaPDFWriteFText.md).  
  
MBS Plugin in version 11.5 with DynaPDF 4.0.62.160 adds support for double underlined text.  
  
Warning: FileMaker does not pass style information from the layout used to give a field as default style. If you put text into a field and use the style of the field, then the plugin doesn't know this detail. You have to explicit use different font for FileMaker to pass it.   
e.g. if your field is set to Verdana 12 and you have "Hello World" inside with Hello using Verdana 12 and World using Times 13, then the plugin would get passed "Hello" without font, since it matches the default for the field.  
See also [WriteStyledText](https://www.monkeybreadsoftware.com/DynaPDF-Manual/WriteFText.shtml) function in DynaPDF manual.

### Examples

Write some styled text on a PDF page:

 Set Variable \[$pdf ; Value:MBS ("[DynaPDF.New](DynaPDFNew.md)")\]  
\#Add page   
Set Variable \[$r ; Value:MBS ("[DynaPDF.AppendPage](DynaPDFAppendPage.md)"; $pdf )\]  
Set Variable \[$r ; Value:MBS ("[DynaPDF.SetFont](DynaPDFSetFont.md)"; $pdf ; "Helvetica"; 0; 12)\]  
\#Write some text   
Set Variable \[$pw ; Value:MBS ("[DynaPDF.GetPageWidth](DynaPDFGetPageWidth.md)"; $pdf )\]  
Set Variable \[$ph ; Value:MBS ("[DynaPDF.GetPageHeight](DynaPDFGetPageHeight.md)"; $pdf )\]  
Set Variable \[$r ; Value:MBS ("[DynaPDF.SetFillColor](DynaPDFSetFillColor.md)"; $pdf ; 0; 0; 0)\]  
Set Variable \[$r ; Value:MBS ("[DynaPDF.SetTextRect](DynaPDFSetTextRect.md)"; $pdf ; 100; $ph -100; $pw -200; $ph -200)\]  
Set Variable \[$r ; Value:MBS ("DynaPDF.WriteStyledText"; $pdf ; "left"; Create Text::Text )\]  
\#End page   
Set Variable \[$r ; Value:MBS ("[DynaPDF.EndPage](DynaPDFEndPage.md)"; $pdf )\]  
\#Render one page as Picture   
Set Variable \[$PDFData ; Value:MBS ("[DynaPDF.Save](DynaPDFSave.md)"; $pdf ; "hello.pdf")\]  
Set Variable \[$r ; Value:MBS ("[DynaPDF.Release](DynaPDFRelease.md)"; $pdf )\]  
\#Put in Container   
Set Field \[Create Text::PDF ; $PDFData \]  
### See also

- [DynaPDF.ConvertStyledText](DynaPDFConvertStyledText.md)
- [DynaPDF.New](DynaPDFNew.md)
- [DynaPDF.Release](DynaPDFRelease.md)
- [DynaPDF.Save](DynaPDFSave.md)
- [DynaPDF.SetPageBreakExpression](DynaPDFSetPageBreakExpression.md)
- [DynaPDF.WriteFText](DynaPDFWriteFText.md)
- [DynaPDF.WriteFTextEx](DynaPDFWriteFTextEx.md)
- [DynaPDF.WriteFTextExRotated](DynaPDFWriteFTextExRotated.md)
- [DynaPDF.WriteStyledTextEx](DynaPDFWriteStyledTextEx.md)
- [DynaPDF.WriteStyledTextExRotated](DynaPDFWriteStyledTextExRotated.md)

### Release notes

- **Version 14.1**
    - Improved font mapping for [DynaPDF.WriteStyledText](https://www.mbsplugins.eu/DynaPDFWriteStyledText.shtml) to better handle bold fonts.
- **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/Book Creation](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/DynaPDF/Book%20Creation.shtml#3ScriptAnchor_)
- [DynaPDF/Live Styled Text](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/DynaPDF/Live%20Styled%20Text.shtml#3ScriptAnchor_)
- [DynaPDF/Multi Column Output](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/DynaPDF/Multi%20Column%20Output.shtml#4ScriptAnchor_)
- [DynaPDF/Page Layouting](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/DynaPDF/Page%20Layouting.shtml#2ScriptAnchor_)
- [DynaPDF/Styled Text](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/DynaPDF/Styled%20Text.shtml#2ScriptAnchor_)

### Blog Entries

- [Page Layouting in DynaPDF](https://www.mbsplugins.de/archive/2024-04-05/Page_Layouting_in_DynaPDF/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 14.1pr5](https://www.mbsplugins.de/archive/2024-03-01/MBS_FileMaker_Plugin_version_1/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)
- [New in MBS FileMaker Plugin 11.0](https://www.mbsplugins.de/archive/2021-01-26/New_in_MBS_FileMaker_Plugin_11/monkeybreadsoftware_blog_filemaker)
- [Neues MBS FileMaker Plugin 11.0](https://www.mbsplugins.de/archive/2021-01-19/Neues_MBS_FileMaker_Plugin_110/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin 11.0 - More than 6400 Functions In One Plugin](https://www.mbsplugins.de/archive/2021-01-19/MBS_FileMaker_Plugin_110_-_Mor/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)
- [Multi Column Output for PDFs with FileMaker](https://www.mbsplugins.de/archive/2020-12-22/Multi_Column_Output_for_PDFs_w/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 27th February 2024

  
[DynaPDF.WriteFTextExRotated](DynaPDFWriteFTextExRotated.md) - [DynaPDF.WriteStyledTextEx](DynaPDFWriteStyledTextEx.md)

[HTML Version](DynaPDFWriteStyledText.shtml)