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, and text alignment 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:

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

Tasks

Creating a Simple-Text Print Formatter

Getting and Setting the Text

Text Attributes for Printed Content

Properties

attributedText

A string of attributed text.

@property(nonatomic,copy) NSAttributedString *attributedText
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.

Assigning a value to this property also replaces the value in the text property with the same string data, albeit without any formatting information.

Availability
  • Available in iOS 7.0 and later.
Declared In
UIPrintFormatter.h

color

The color of the printed text.

@property(nonatomic, retain) UIColor *color
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.h

font

The font of the printed text.

@property(nonatomic, retain) UIFont *font
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.h

text

A string of plain text.

@property(nonatomic, copy) NSString *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.

Assigning a value to this property replaces the value in the attributedText property with the same string data, albeit without any inherent style attributes. Instead, the print formatter styles the new string using the text attribute properties of this class.

Availability
  • Available in iOS 4.2 and later.
Declared In
UIPrintFormatter.h

textAlignment

The alignment of the printed text.

@property(nonatomic) UITextAlignment textAlignment
Discussion

The default text alignment is UITextAlignmentLeft.

Availability
  • Available in iOS 4.2 and later.
Declared In
UIPrintFormatter.h

Instance Methods

initWithAttributedText:

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

- (instancetype)initWithAttributedText:(NSAttributedString *)attributedText
Parameters
attributedText

A string of attributed text or nil if 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 7.0 and later.
Declared In
UIPrintFormatter.h

initWithText:

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

- (id)initWithText:(NSString *)text
Parameters
text

A string of plain text or nil if 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