UISimpleTextPrintFormatter Class Reference
| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/UIKit.framework |
| Availability | Available in iOS 4.2 and later. |
| Companion guide | |
| Declared in | UIPrintFormatter.h |
Overview
Instances of the UISimpleTextPrintFormatter class lay out plain text for printing, possibly over multiple pages. The class allows you to specify global font, color, line-alignment, and linebreak-mode properties for the printed text.
To use this print formatter for a print job, create an instance of UISimpleTextPrintFormatter 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
printFormatterproperty of theUIPrintInteractionControllershared instance. The inheritedstartPageproperty 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
UIPrintPageRendererobject:You can add print formatters to the
printFormattersproperty of theUIPrintPageRendererobject; thestartPageproperty of the print formatter specifies the starting pageYou can add print formatters by calling
addPrintFormatter:startingAtPageAtIndex:for each print formatter; the second parameter of this method specifies the starting page (and overrides anystartPagevalue).
You can change the text at any time before drawing of the printable content begins.
Tasks
Creating a Simple-Text Print Formatter
Getting and Setting the Text
-
textproperty
Text Attributes for Printed Content
-
fontproperty -
colorproperty -
lineBreakModeproperty -
textAlignmentproperty
Properties
color
The color of the printed text.
Discussion
If the value of this property is nil (the default), UIKit uses a black color when printing.
Availability
- Available in iOS 4.2 and later.
Declared In
UIPrintFormatter.hfont
The font of the printed text.
Discussion
If the value of this property is nil (the default), UIKit uses the standard system font, 12 points.
Availability
- Available in iOS 4.2 and later.
Declared In
UIPrintFormatter.hlineBreakMode
The line-break mode of the printed text.
Discussion
The default line-break mode is UILineBreakModeWordWrap.
text
A string of plain text.
Discussion
You cannot change the value of this property once drawing begins for a print job. The delegate method printInteractionControllerWillStartJob: is called immediately before the formatting is set for the job.
Availability
- Available in iOS 4.2 and later.
See Also
Declared In
UIPrintFormatter.htextAlignment
The alignment of the printed text.
Discussion
The default text alignment is UITextAlignmentLeft.
Availability
- Available in iOS 4.2 and later.
Declared In
UIPrintFormatter.hInstance Methods
initWithText:
Returns a simple-text print formatter initialized with plain text.
Parameters
- text
A string of plain text or
nilif you intend to assign the text later.
Return Value
An initialized instance of UISimpleTextPrintFormatter or nil if the object could not be created.
Availability
- Available in iOS 4.2 and later.
See Also
Declared In
UIPrintFormatter.h© 2010 Apple Inc. All Rights Reserved. (Last updated: 2010-10-12)