Class

UIPrintInteractionController

The shared instance of the UIPrintInteractionController class presents a printing user interface and manages the printing of documents, images, and other printable content in iOS.

Overview

UIPrintInteractionController is the central class for printing in iOS. The shared instance of it represents a print job. A print job includes the content to be printed and information and options related to its printing, such as output type, job name, paper size, and orientation.

UIPrintInteractionController has four mutually exclusive properties for giving it the content to be printed:

  • printingItem takes a single print-ready object.

  • printingItems takes an array of print-ready objects.

  • printFormatter takes a print formatter, an object that knows how to lay out content of a certain type.

  • printPageRenderer takes a page renderer, a custom object that draws the content for printing.

If the showsPageRange property is set to true, the number of pages is more than 1, and you assign an object to any of these properties except for the printingItems property, the printing options include a control that allows users to select a page range.

When users tap a print button on the application’s user interface, a controller object of the application should respond to the action message by obtaining the shared instance of UIPrintInteractionController and preparing it for the print job. When the application calls one of the present... methods (for example, present(animated:completionHandler:)), UIPrintInteractionController displays a view containing printing options. This interface is simple, allowing users to select a printer, specify the number of copies and possibly a range of pages, and choose single-sided or double-sided printing (if the printer supports duplex printing). When users make their selections and tap Print, the print job begins.

Symbols

Determining Printability

class func canPrint(Data)

Returns whether UIKit can print the contents of a data object.

class func canPrint(URL)

Returns whether UIKit can print the file referenced by a URL.

Providing the Source of Printable Content

var printingItem: Any?

A single ready-to-print object.

var printingItems: [Any]?

An array of ready-to-print objects.

var printPageRenderer: UIPrintPageRenderer?

An object that draws pages of printable content when requested by UIKit.

var printFormatter: UIPrintFormatter?

An object that lays out the content of pages based on the kind of content.

Presenting the Printing User Interface

func present(animated: Bool, completionHandler: UIPrintInteractionCompletionHandler? = nil)

Presents the iPhone printing user interface in a sheet that can be animated to slide up from the bottom of the screen.

func present(from: UIBarButtonItem, animated: Bool, completionHandler: UIPrintInteractionCompletionHandler? = nil)

Presents the iPad printing user interface in a popover view that can be animated from a bar-button item.

func present(from: CGRect, in: UIView, animated: Bool, completionHandler: UIPrintInteractionCompletionHandler? = nil)

Presents the iPad printing user interface in a popover view that can be animated from any area in a view.

func dismiss(animated: Bool)

Dismisses the printing-options sheet or popover.

Printing Directly to a Printer

Accessing Print-Job Information

var printInfo: UIPrintInfo?

An object encapsulating information about the print job.

var printPaper: UIPrintPaper?

An object representing the paper size and printing area for the print job.

var showsNumberOfCopies: Bool

A Boolean value that determines whether the printing options include the number of copies.

var showsPageRange: Bool

A Boolean value that determines whether the printing options include a page-range control.

Deprecated
var showsPaperSelectionForLoadedPapers: Bool

A Boolean value for enabling the paper selection menu.

Assigning the Delegate

var delegate: UIPrintInteractionControllerDelegate?

The delegate of the print interaction controller.

Constants

UIPrintInteractionCompletionHandler

The type of block callback for responding to the completion of a print job or handing printing errors.

UIKit Printing Error Domain

The error domain for printer errors

UIKit Printing Error Codes

Error codes for UIKit printing errors.

Relationships

Inherits From

Conforms To