Class

NSPrintInfo

An object that stores information that’s used to generate printed output.

Overview

A shared NSPrintInfo object is automatically created for an app and is used by default for all printing jobs for that app. The printing information in an NSPrintInfo object is stored in a dictionary. To access the standard attributes in the dictionary directly, this class defines a set of keys and provides the dictionary() method. You can also initialize an instance of this class using the init(dictionary:) method.

You can use this dictionary to store custom information associated with a print job. Any non-object values should be stored as NSNumber or NSValue objects in the dictionary. See NSNumber for a list of types which should be stored as numbers. For other non-object values, use the NSValue class.

To store custom information that belongs in printing presets you should use the dictionary returned by the printSettings method.

Topics

Initializing an NSPrintInfo

init(dictionary: [NSPrintInfo.AttributeKey : Any])

Returns an NSPrintInfo object initialized with the parameters in the specified dictionary.

Managing the Shared NSPrintInfo

class var shared: NSPrintInfo

Returns the shared NSPrintInfo object.

Managing the Printing Rectangle

var bottomMargin: CGFloat

The height of the bottom margin.

var imageablePageBounds: NSRect

The imageable area of a sheet of paper specified by the receiver.

var leftMargin: CGFloat

The width of the left margin.

var paperName: NSPrinter.PaperName?

The name of the currently selected paper size.

var localizedPaperName: String?

The human-readable name of the currently selected paper size, suitable for presentation in user interfaces.

var paperSize: NSSize

The size of the paper.

var rightMargin: CGFloat

The width of the right margin.

var topMargin: CGFloat

The top margin to the specified size.

Pagination

var verticalPagination: NSPrintInfo.PaginationMode

the vertical pagination to the specified mode.

Positioning the Image on the Page

var isHorizontallyCentered: Bool

A Boolean value indicating whether the image is centered horizontally.

var isVerticallyCentered: Bool

A Boolean value indicating whether the image is centered vertically.

Specifying the Printer

var printer: NSPrinter

The NSPrinter object to be used for printing.

Controlling Printing

var jobDisposition: NSPrintInfo.JobDisposition

The action specified for the job.

func setUpPrintOperationDefaultValues()

Validates the attributes encapsulated by the receiver.

Accessing the Print Info Dictionary

func dictionary()

Returns the receiver’s dictionary that contains the printing attributes.

Print Settings Convenience Methods

var isSelectionOnly: Bool

A Boolean that indicates whether only the currently selected contents should be printed.

var scalingFactor: CGFloat

The current scaling factor.

Accessing Core Printing Information

var printSettings: NSMutableDictionary

A mutable dictionary containing the print settings from Core Printing.

func pmPrintSession()

Returns a Core Printing object configured with the receiver’s session information.

func pmPageFormat()

Returns a Core Printing object configured with the receiver’s page format information.

func pmPrintSettings()

Returns a Core Printing object configured with the receiver’s print settings information

func updateFromPMPageFormat()

Synchronizes the receiver’s page format information with information from its associated PMPageFormat object.

func updateFromPMPrintSettings()

Synchronizes the receiver’s print settings information with information from its associated PMPrintSettings object.

Deprecated Methods

Constants

Print job attributes

These constants specify dictionary keys to access print job attributes.

enum NSPrintInfo.PaginationMode

These constants specify the different ways in which an image is divided into pages. They’re used by horizontalPagination, and verticalPagination.

enum NSPrintInfo.Orientation

These constants specify page orientations used by the property orientation.

Print job dispositions

These constants specify valid values for the print job attribute jobDisposition. These constants are used the jobDisposition property.

Page setup attributes

These constants specify dictionary keys to access page format attributes.

Pagination attributes

These constants specify dictionary keys to access pagination attributes.

Relationships

Inherits From

See Also

Print Job Information

class NSPrinter

An object that describes a printer’s capabilities.

class NSPrintOperation

An object that controls operations that generate Encapsulated PostScript (EPS) code, Portable Document Format (PDF) code, or print jobs.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software