An NSPrintInfo object stores information that’s used to generate printed output. A shared NSPrintInfo object is automatically created for an application and is used by default for all printing jobs for that application.

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 initWithDictionary: 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 Class Reference for a list of types which should be stored as numbers. For other non-object values, use the NSValue class.

Beginning with OS X v10.5, to store custom information that belongs in printing presets you should use the dictionary returned by the printSettings method.

Declaration

Parameters

aDictionary

The possible key-value pairs contained in aDictionary are described in Constants.

Return Value

An initialized NSPrintInfo object, or nil if the object could not be created.

Discussion

This method is the designated initializer for this class. Non-object values should be stored in NSValue objects (or an appropriate subclass like NSNumber) in the dictionary. See NSNumber for a list of types which should be stored using the NSNumber class; otherwise use NSValue.

Import Statement

Availability

See Also

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

Declaration

Swift

var imageablePageBounds: NSRect { get }

Objective-C

@property(readonly) NSRect imageablePageBounds

Return Value

The imageable area, measured in points in the user coordinate space.

Discussion

This method takes into account the current printer, paper size, and orientation settings, but not scaling factors. “Imageable area” is the maximum area that can possibly be marked on by the printer hardware, not the area defined by the current margin settings.

The origin (0, 0) of the returned rectangle is in the lower-left corner of the oriented sheet. The imageable bounds may extend past the edges of the sheet when, for example, a printer driver specifies it so that borderless printing can be done reliably.

Import Statement

Availability

See Also

Declaration

Swift

@NSCopyingvar printer: NSPrinter

Objective-C

@property(copy) NSPrinter *printer

Parameters

printer

The printer object.

Discussion

This method iterates through the receiver's dictionary. If a feature in the dictionary is not supported by the new printer (as determined by a query to the PPD file), that feature is removed from the dictionary.

Declaration

Return Value

A mutable dictionary containing the printing system’s current settings.

Discussion

You can use this method to get and set values from the system print settings. The keys in the returned dictionary represent the values returned by the Core Printing function PMPrintSettingsGetValue. They correspond to the settings currently in the print panel and include everything from custom values set by your accessory panels to values provided by the printer driver’s print dialog extension.

Adding keys to the dictionary is equivalent to calling the Core Printing function PMPrintSettingsSetValue. Your new keys are added to the current print settings and are saved with any user preset files generated by the OS X printing system. Because the print settings are stored in a property list, any values you add to the dictionary must correspond to scalar types such as strings, numbers, dates, booleans, and data objects or collection types such as dictionaries and arrays.

Other parts of the printing system use key strings like com.apple.print.PrintSettings.PMColorSyncProfileID to identify print settings. Cocoa replaces the periods in such strings with underscores. Thus, the preceding key string would be com_apple_print_PrintSettings_PMColorSyncProfileID instead. If you use reverse-DNS style key strings for your custom attributes, you should follow the same convention of using underscore characters instead of periods.

Availability

Declaration

Swift

funcPMPrintSession() -> UnsafeMutablePointer<Void>

Objective-C

- (void *)PMPrintSession

Return Value

A pointer to a PMPrintSession object, an opaque type that stores information about a print job. You should not call PMRelease to release the returned object, except to balance calls to PMRetain that your code also issued.

Discussion

The information in the returned PMPrintSession object is consistent with the receiver’s session information at the time this method is called. Subsequent changes to the receiving NSPrintInfo object do not result in changes to the information in the PMPrintSession object.

Availability

Declaration

Swift

funcPMPageFormat() -> UnsafeMutablePointer<Void>

Objective-C

- (void *)PMPageFormat

Return Value

A pointer to a PMPageFormat object, an opaque data type that stores information such as the paper size, orientation, and scale of pages in a printing session. You should not call PMRelease to release the returned object, except to balance calls to PMRetain that your code also issued.

Discussion

The information in the returned PMPageFormat object is consistent with the receiver’s page format information at the time this method is called. Subsequent changes to the receiving NSPrintInfo object do not result in changes to the information in the PMPageFormat object.

If you make changes to the data in the PMPageFormat object, you should invoke the updateFromPMPageFormat method to synchronize those changes with the NSPrintInfo object that created the object.

Availability

See Also

Declaration

Swift

funcPMPrintSettings() -> UnsafeMutablePointer<Void>

Objective-C

- (void *)PMPrintSettings

Return Value

A pointer to a PMPrintSettings object, an opaque data type used to store information such as the number of copies and the range of pages in a printing session. You should not call PMRelease to release the returned object, except to balance calls to PMRetain that your code also issued.

Discussion

The information in the returned PMPrintSettings object is consistent with the receiver’s print settings at the time this method is called. Subsequent changes to the receiving NSPrintInfo object do not result in changes to the information in the PMPrintSettings data type.

If you make changes to the data in the PMPrintSettings object, you should invoke the updateFromPMPrintSettings method to synchronize those changes with the NSPrintInfo object that created the object.

Import Statement

Availability

See Also

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

Declaration

Swift

funcupdateFromPMPageFormat()

Objective-C

- (void)updateFromPMPageFormat

Discussion

You should use this method after making changes to the PMPageFormat object obtained from the receiver. Each NSPrintInfo object keeps track of the object returned from its PMPageFormat method and obtains any updated information from the object directly. You only need to synchronize the objects once when you have made all of the desired changes.

Import Statement

Availability

See Also

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

Declaration

Swift

funcupdateFromPMPrintSettings()

Objective-C

- (void)updateFromPMPrintSettings

Discussion

You should use this method after making changes to the PMPrintSettings object obtained from the receiver. Each NSPrintInfo object keeps track of the object returned from its PMPrintSettings method and obtains any updated information from the object directly. You only need to synchronize the objects once when you have made all of the desired changes.