iOS Developer Library

Developer

UIKit Framework Reference UIPrintPaper Class Reference

Options
Deployment Target:

On This Page
Language:

UIPrintPaper

An instance of the UIPrintPaper class encapsulates the size of paper used for a print job and the rectangle in which content can be printed.

In most cases, UIKit automatically creates an instance of UIPrintPaper that is appropriate for a print job. The UIKit framework has default paper sizes based on a print job’s output type (outputType is a property of the UIPrintInfo class). If the output type is UIPrintInfoOutputPhoto, the default paper size is 4x6 or A6 or some other standard size, depending on locale; if the output type is UIPrintInfoOutputGeneral or UIPrintInfoOutputGrayscale, the default paper size is US Letter (8 1/2 by 11 inches) or A4 or some other standard size, depending on locale.

Applications may have special requirements for paper sizes. For example, a word-processing application may have items of “stationery” in which printable content must be drawn. If your application fits the special case, the delegate of UIPrintInteractionController can implement the printInteractionController:choosePaper: method of the UIPrintInteractionControllerDelegate protocol to return a suitable UIPrintPaper object. One way to do this is to call the bestPaperForPageSize:withPapersFromArray: class method of UIPrintPaper, passing in a array of UIPrintPaper objects representing the paper sizes supported by a printer. The UIPrintPaper object returned from this method represents the paper size best matched to the size requirement of the application.

The printable rectangle (printableRect) is the imageable area for the printer on a paper of a given size.

If you are using a UIPrintPageRenderer object to draw the content for printing, the rectangle stored in the printableRect property is stored in the page renderer’s property of the same name and the paper size used for a print job is stored as part of the paperRect property.

Inheritance


Conforms To


Import Statement


Swift

import UIKit

Objective-C

@import UIKit;

Availability


Available in iOS 4.2 and later.
  • paperSize paperSize Property

    The size of the sheet to be used for printing. (read-only)

    Declaration

    Swift

    var paperSize: CGSize { get }

    Objective-C

    @property(readonly) CGSize paperSize

    Discussion

    The paper size is often associated with a standard designation, such as “Letter” and “A4”. For example, the paper size for a Letter sheet of paper is 612 points wide and 792 points high.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 4.2 and later.

    See Also

    printableRect

  • The rectangle that represents the portion of the paper that can be imaged upon. (read-only)

    Declaration

    Swift

    var printableRect: CGRect { get }

    Objective-C

    @property(readonly) CGRect printableRect

    Discussion

    Typically, UIKit passes this value into the last argument of the UIPrintPageRenderer method drawPageAtIndex:inRect:.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 4.2 and later.

    See Also

    paperSize

  • Returns the print-paper object that UIKit determines to be the best for a print job based on the given page size and the paper size–imageable area combinations specific to the printer.

    Declaration

    Swift

    class func bestPaperForPageSize(_ pageSize: CGSize, withPapersFromArray paperList: [AnyObject]!) -> UIPrintPaper?

    Objective-C

    + (UIPrintPaper *)bestPaperForPageSize:(CGSize)pageSize withPapersFromArray:(NSArray *)paperList

    Parameters

    pageSize

    The size of the printed page that your application requests, in points. You should think of this as the size of the physical sheet of paper to use in printing without consideration of the margin.

    paperList

    An array of UIPrintPaper objects that represent combinations of supported paper size and printable areas. The array of objects usually comes directly from the second argument of the printInteractionController:choosePaper: method of the UIPrintInteractionControllerDelegate protocol.

    Return Value

    An instance of UIPrintPaper that represents the optimal printable area and paper size for the current print job. Returns nil if the instance could not be created.

    Discussion

    The delegate of UIPrintInteractionController may call this method in its implementation of the printInteractionController:choosePaper: method declared in the UIPrintInteractionControllerDelegate protocol.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 4.2 and later.