Class

# StyledTextPrinter

<div class="rst-class">

forsearch

</div>

Printing

<div class="rst-class">

forsearch

</div>

Print

<div class="rst-class">

forsearch

</div>

StyledText

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Description

Used to print styled text stored in a `TextArea</api/user_interface/desktop/desktoptextarea>`.

## Properties

<div class="rst-class">

table-centered_columns_3_and_4

</div>

| Name                             | Type                               | Read-Only | Shared |
|----------------------------------|------------------------------------|-----------|--------|
| `EOF<styledtextprinter.eof>`     | `Boolean</api/data_types/boolean>` | ✓         |        |
| `Width<styledtextprinter.width>` | `Integer</api/data_types/integer>` |           |        |

## Methods

<div class="rst-class">

table-centered_column_4

</div>

| Name                                     | Parameters                                                                                                                     | Returns | Shared |
|------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------|---------|--------|
| `DrawBlock<styledtextprinter.drawblock>` | x As `Integer</api/data_types/integer>`, y As `Integer</api/data_types/integer>`, Height As `Integer</api/data_types/integer>` |         |        |

## Property descriptions

<div id="styledtextprinter.eof">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

StyledTextPrinter.EOF

**EOF** As `Boolean</api/data_types/boolean>`

> `True</api/language/true>` when there is no more text to print in the `TextArea</api/user_interface/desktop/desktoptextarea>`.
>
> This property is read-only.
>
> Use it to determine when to stop calling DrawBlock. See the examples.

<div id="styledtextprinter.width">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

StyledTextPrinter.Width

**Width** As `Integer</api/data_types/integer>`

> The width of the text to be printed.

## Method descriptions

<div id="styledtextprinter.drawblock">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

StyledTextPrinter.DrawBlock

**DrawBlock**(x As `Integer</api/data_types/integer>`, y As `Integer</api/data_types/integer>`, Height As `Integer</api/data_types/integer>`)

> Used to print the styled text.
>
> The parameters *x* and *y* are coordinates of the point at which you want to begin printing the text. *x* and *y* are offset from the top-left corner of the printable area as defined in Page Setup.

## Notes

<span class="title-ref">StyledTextPrinter</span> is not supported on Windows and will raise an `UnsupportedOperationException</api/exceptions/unsupportedoperationexception>` if called.

## Sample code

The following code prints the styled text in a `TextArea</api/user_interface/desktop/desktoptextarea>`. The `TextArea</api/user_interface/desktop/desktoptextarea>`'s MultiLine and Styled properties must be set to `True</api/language/true>` to accept and print styled text.

``` xojo
Var stp As StyledTextPrinter
Var g As Graphics
g = OpenPrinterDialog
If g <> Nil Then
  ' 72 pixels per inch * 7.5 inches
  Var textWidth As Integer = 72 * 7.5
  stp = TextArea1.StyledTextPrinter(g, textWidth)
  stp.DrawBlock(0, 0, 72 * 10)
End If
```

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

This code prints the contents of TextArea1 in two columns with a quarter-inch of spacing between them. The EOF property is used to determine if all the text has been printed. When EOF is `False</api/language/false>`, it prints the second column or prints another page.

``` xojo
Var g As Graphics
Var stp As StyledTextPrinter
Var columnWidth, spaceBetweenColumns, pageHeight As Integer
Var columnToPrint As Integer
columnWidth = 261
' 7.5 inches minus 1/4 inch for space
' divided by 2
spaceBetweenColumns = 18
' 18 pixels is 1/4 inch
pageHeight = 10 * 72
' 10 inches * 72 pixels per inch
g = OpenPrinterDialog
If g <> Nil Then
  stp = TextArea1.StyledTextPrinter(g, 540)
  stp.Width = columnWidth
  columnToPrint = 1
  Do Until stp.EOF
    stp.DrawBlock((columnWidth + spaceBetweenColumns) * (columnToPrint - 1), 0, PageHeight)
    If columnToPrint = 2 Then ' printing last column
      If Not stp.EOF Then ' more text to print
        g.NextPage
        columnToPrint = 1
      End If
    Else ' more columns to print on this page
      columnToPrint = columnToPrint + 1
    End If
  Loop
End If
```

## Compatibility

|                       |              |
|-----------------------|--------------|
| **Project Types**     | Desktop      |
| **Operating Systems** | Linux, macOS |

<div class="seealso">

`Object</api/data_types/additional_types/object>` parent class; `TextArea</api/user_interface/desktop/desktoptextarea>` control; `PrinterSetup.OpenPrinter<printersetup.openprinter>`, `ShowPrinterDialog<printersetup.showprinterdialog>` functions; `Graphics</api/graphics/graphics>`, `PrinterSetup</api/printing/printersetup>` classes.

</div>
