Class

NSPrintOperation

An NSPrintOperation object controls operations that generate Encapsulated PostScript (EPS) code, Portable Document Format (PDF) code, or print jobs. An NSPrintOperation object works in conjunction with two other objects: an NSPrintInfo object, which specifies how the code should be generated, and an NSView object, which generates the actual code.

Overview

It is important to note that the majority of methods in NSPrintOperation copy the instance of NSPrintInfo passed into them. Future changes to that print info are not reflected in the print info retained by the current NSPrintOperation object. All changes should be made to the print info before passing to the methods of this class. The only method in NSPrintOperation which does not copy the NSPrintInfo instance is printInfo.

Symbols

Creating an NSPrintOperation

class func epsOperation(with: NSView, inside: NSRect, to: NSMutableData?)

Creates and returns a new NSPrintOperation object ready to control the copying of EPS graphics from the specified view.

class func epsOperation(with: NSView, inside: NSRect, to: NSMutableData, printInfo: NSPrintInfo)

Creates and returns a new NSPrintOperation object ready to control the copying of EPS graphics from the specified view using the specified print settings.

class func epsOperation(with: NSView, inside: NSRect, toPath: String, printInfo: NSPrintInfo)

Creates and returns a new NSPrintOperation object ready to control the copying of EPS graphics from the specified view and write the resulting data to the specified file.

class func pdfOperation(with: NSView, inside: NSRect, to: NSMutableData)

Creates and returns a new NSPrintOperation object ready to control the copying of PDF graphics from the specified view.

class func pdfOperation(with: NSView, inside: NSRect, to: NSMutableData, printInfo: NSPrintInfo)

Creates and returns a new NSPrintOperation object ready to control the copying of PDF graphics from the specified view using the specified print settings.

class func pdfOperation(with: NSView, inside: NSRect, toPath: String, printInfo: NSPrintInfo)

Creates and returns a new NSPrintOperation object ready to control the copying of PDF graphics from the specified view and write the resulting data to the specified file.

init(view: NSView)

Creates and returns an NSPrintOperation object ready to control the printing of the specified view.

init(view: NSView, printInfo: NSPrintInfo)

Creates and returns an NSPrintOperation object ready to control the printing of the specified view using custom print settings.

Setting the Current NSPrintOperation for This Thread

class func current()

Returns the current print operation for this thread.

class func setCurrent(NSPrintOperation?)

Sets the current print operation for this thread.

Modifying the NSPrintInfo Object

var printInfo: NSPrintInfo

Sets the receiver’s NSPrintInfo object.

Getting the NSView Object

var view: NSView?

Returns the view object that generates the actual data for the print operation.

Printing Quality

Running a Print Operation

func run()

Runs the print operation on the current thread.

func runModal(for: NSWindow, delegate: Any?, didRun: Selector?, contextInfo: UnsafeMutableRawPointer?)

Runs the print operation, calling your custom delegate method upon completion.

func cleanUp()

Called at the end of a print operation to remove the receiver as the current operation.

func deliverResult()

Delivers the results of the print operation to the intended destination.

Modifying the User Interface

var showsPrintPanel: Bool

Sets whether the receiver displays a print panel for this operation.

var showsProgressPanel: Bool

Sets whether the receiver displays a progress panel for this operation.

var jobTitle: String?

Assigns a custom title to the print job.

var printPanel: NSPrintPanel

Sets the NSPrintPanel object to be used during the operation.

Managing the Drawing Context

var context: NSGraphicsContext?

Returns the graphics context object used for generating output.

func createContext()

Creates the graphics context object used for drawing during the operation.

func destroyContext()

Destroys the receiver’s graphics context.

Managing Page Information

var currentPage: Int

Returns the current page number being printed.

var pageRange: NSRange

Returns the range of pages associated with the print operation.

var pageOrder: NSPrintingPageOrder

Sets the print order for the pages of the operation.

Managing Printing-Related Threads

var canSpawnSeparateThread: Bool

Sets whether the receiver is allowed to spawn a separate printing thread.

Constants

NSPrintingPageOrder

These constants specify the page order.

Exception Name

This is the name of an exception that can be raised by NSPrintOperation.

NSPrintRenderingQuality

These constants specify the print quality in use.

Relationships

Inherits From

Conforms To