Class

UISimple​Text​Print​Formatter

Instances of the UISimple​Text​Print​Formatter class lay out plain text for printing, possibly over multiple pages. The class allows you to specify global font, color, and text alignment properties for the printed text.

Overview

To use this print formatter for a print job, create an instance of UISimple​Text​Print​Formatter initialized with the text, set the text properties and the inherited layout properties, and add the object to the print job in one of two ways:

  • If a single print formatter is being used for the print job (with no additional drawing), assign it to the print​Formatter property of the UIPrint​Interaction​Controller shared instance. The inherited start​Page property identifies the beginning page of content with which the formatter is associated.

  • If you are using multiple formatters along with a page renderer, associate each print formatter with a starting page of the printed content. You often take this approach when you want to add content such as headers and footers to what the formatters provide. You have two ways of associating a print formatter with a UIPrint​Page​Renderer object:

    • You can add print formatters to the print​Formatters property of the UIPrint​Page​Renderer object; the start​Page property of the print formatter specifies the starting page.

    • You can add print formatters by calling add​Print​Formatter(_:​starting​At​Page​At:​) for each print formatter; the second parameter of this method specifies the starting page (and overrides any start​Page value).

You can change the text at any time before drawing of the printable content begins. You cannot change the text after drawing begins.

Symbols

Creating a Simple-Text Print Formatter

init(attributed​Text:​ NSAttributed​String)

Returns a simple-text print formatter initialized with attributed text.

init(text:​ String)

Returns a simple-text print formatter initialized with plain text.

Getting and Setting the Text

var text:​ String?

A string of plain text.

Text Attributes for Printed Content

var font:​ UIFont?

The font of the printed text.

var color:​ UIColor?

The color of the printed text.

var text​Alignment:​ NSText​Alignment

The alignment of the printed text.

Relationships

Inherits From