| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/AppKit.framework |
| Availability | Available in Mac OS X v10.0 and later.
|
| Companion guide | |
| Declared in | NSPrintOperation.h |
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.
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 setPrintInfo:.
Note: You should not subclass NSPrintOperation. Methods that return an NSPrintOperation object return an instance of a concrete subclass whose implementation is private.
+ EPSOperationWithView:insideRect:toData:
+ EPSOperationWithView:insideRect:toData:printInfo:
+ EPSOperationWithView:insideRect:toPath:printInfo:
+ PDFOperationWithView:insideRect:toData:
+ PDFOperationWithView:insideRect:toData:printInfo:
+ PDFOperationWithView:insideRect:toPath:printInfo:
+ printOperationWithView:
+ printOperationWithView:printInfo:
– runOperation
– runOperationModalForWindow:delegate:didRunSelector:contextInfo:
– cleanUpOperation
– deliverResult
– showsPrintPanel
– setShowsPrintPanel:
– showsProgressPanel
– setShowsProgressPanel:
– jobTitle
– setJobTitle:
– printPanel
– setPrintPanel:
– setShowPanels: Deprecated in Mac OS X v10.4 and later
– showPanels Deprecated in Mac OS X v10.4 and later
– accessoryView Deprecated in Mac OS X v10.5
– jobStyleHint Deprecated in Mac OS X v10.5
– setAccessoryView: Deprecated in Mac OS X v10.5
– setJobStyleHint: Deprecated in Mac OS X v10.5
Returns the current print operation for this thread.
+ (NSPrintOperation *)currentOperation
The print operation object, or nil if there is no current operation.
NSPrintOperation.h
Creates and returns a new NSPrintOperation object ready to control the copying of EPS graphics from the specified view.
+ (NSPrintOperation *)EPSOperationWithView:(NSView *)aView insideRect:(NSRect)rect toData:(NSMutableData *)data
The view containing the data to be turned into EPS data.
The portion of the view (specified in points in the view's coordinate space) to be rendered as EPS data.
An empty NSMutableData object. After the job is run, this object contains the EPS data.
The new NSPrintOperation object. You must run the operation to generate the EPS data.
The new NSPrintOperation object uses the default NSPrintInfo object. This method raises an NSPrintOperationExistsException if there is already a print operation in progress; otherwise the returned object is made the current print operation for this thread.
+ EPSOperationWithView:insideRect:toData:printInfo:+ EPSOperationWithView:insideRect:toPath:printInfo:– runOperationNSPrintOperation.h
Creates and returns a new NSPrintOperation object ready to control the copying of EPS graphics from the specified view using the specified print settings.
+ (NSPrintOperation *)EPSOperationWithView:(NSView *)aView insideRect:(NSRect)rect toData:(NSMutableData *)data printInfo:(NSPrintInfo *)aPrintInfo
The view containing the data to be turned into EPS data.
The portion of the view (specified in points in the view's coordinate space) to be rendered as EPS data.
An empty NSMutableData object. After the job is run, this object contains the EPS data.
The print settings to use when generating the EPS data.
The new NSPrintOperation object. You must run the operation to generate the EPS data.
This method raises an NSPrintOperationExistsException if there is already a print operation in progress; otherwise the returned object is made the current print operation for this thread.
+ EPSOperationWithView:insideRect:toData:+ EPSOperationWithView:insideRect:toPath:printInfo:– runOperationNSPrintOperation.h
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.
+ (NSPrintOperation *)EPSOperationWithView:(NSView *)aView insideRect:(NSRect)rect toPath:(NSString *)path printInfo:(NSPrintInfo *)aPrintInfo
The view containing the data to be turned into EPS data.
The portion of the view (specified in points in the view's coordinate space) to be rendered as EPS data.
The path to a file. After the job is run, this file contains the EPS data.
The print settings to use when generating the EPS data.
The new NSPrintOperation object. You must run the operation to generate the EPS data.
This method raises an NSPrintOperationExistsException if there is already a print operation in progress; otherwise the returned object is made the current print operation for this thread.
+ EPSOperationWithView:insideRect:toData:+ EPSOperationWithView:insideRect:toData:printInfo:– runOperationNSPrintOperation.h
Creates and returns a new NSPrintOperation object ready to control the copying of PDF graphics from the specified view.
+ (NSPrintOperation *)PDFOperationWithView:(NSView *)aView insideRect:(NSRect)rect toData:(NSMutableData *)data
The view containing the data to be turned into PDF data.
The portion of the view (specified in points in the view's coordinate space) to be rendered as PDF data.
An empty NSMutableData object. After the job is run, this object contains the PDF data.
The new NSPrintOperation object. You must run the operation to generate the PDF data.
The new NSPrintOperation object uses the default NSPrintInfo object. This method raises an NSPrintOperationExistsException if there is already a print operation in progress; otherwise the returned object is made the current print operation for this thread.
+ PDFOperationWithView:insideRect:toData:printInfo:+ PDFOperationWithView:insideRect:toPath:printInfo:– runOperationNSPrintOperation.h
Creates and returns a new NSPrintOperation object ready to control the copying of PDF graphics from the specified view using the specified print settings.
+ (NSPrintOperation *)PDFOperationWithView:(NSView *)aView insideRect:(NSRect)rect toData:(NSMutableData *)data printInfo:(NSPrintInfo *)aPrintInfo
The view containing the data to be turned into PDF data.
The portion of the view (specified in points in the view's coordinate space) to be rendered as PDF data.
An empty NSMutableData object. After the job is run, this object contains the PDF data.
The print settings to use when generating the PDF data.
The new NSPrintOperation object. You must run the operation to generate the PDF data.
This method raises an NSPrintOperationExistsException if there is already a print operation in progress; otherwise the returned object is made the current print operation for this thread.
+ PDFOperationWithView:insideRect:toData:+ PDFOperationWithView:insideRect:toPath:printInfo:– runOperationNSPrintOperation.h
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.
+ (NSPrintOperation *)PDFOperationWithView:(NSView *)aView insideRect:(NSRect)rect toPath:(NSString *)path printInfo:(NSPrintInfo *)aPrintInfo
The view containing the data to be turned into PDF data.
The portion of the view (specified in points in the view's coordinate space) to be rendered as PDF data.
The path to a file. After the job is run, this file contains the PDF data.
The print settings to use when generating the PDF data.
The new NSPrintOperation object. You must run the operation to generate the PDF data.
This method raises an NSPrintOperationExistsException if there is already a print operation in progress; otherwise the returned object is made the current print operation for this thread.
+ PDFOperationWithView:insideRect:toData:+ PDFOperationWithView:insideRect:toData:printInfo:– runOperationNSPrintOperation.hCreates and returns an NSPrintOperation object ready to control the printing of the specified view.
+ (NSPrintOperation *)printOperationWithView:(NSView *)aView
The view whose contents you want to print.
The new NSPrintOperation object. You must run the operation to print the view.
The new NSPrintOperation object uses the settings stored in the shared NSPrintInfo object. This method raises an NSPrintOperationExistsException if there is already a print operation in progress; otherwise the returned object is made the current print operation for this thread.
NSPrintOperation.hCreates and returns an NSPrintOperation object ready to control the printing of the specified view using custom print settings.
+ (NSPrintOperation *)printOperationWithView:(NSView *)aView printInfo:(NSPrintInfo *)aPrintInfo
The view whose contents you want to print.
The print settings to use when printing the view.
The new NSPrintOperation object. You must run the operation to print the view.
This method raises an NSPrintOperationExistsException if there is already a print operation in progress; otherwise the returned object is made the current print operation for this thread.
NSPrintOperation.hSets the current print operation for this thread.
+ (void)setCurrentOperation:(NSPrintOperation *)operation
The print operation to make current. You may specify nil to clear the current print operation.
NSPrintOperation.hReturns a Boolean value indicating whether the receiver is allowed to spawn a separate printing thread.
- (BOOL)canSpawnSeparateThread
YES if the receiver is allowed to spawn a separate thread; otherwise, NO.
NSPrintOperation.h
Called at the end of a print operation to remove the receiver as the current operation.
- (void)cleanUpOperation
You typically do not invoke this method directly.
NSPrintOperation.hReturns the graphics context object used for generating output.
- (NSGraphicsContext *)context
The graphics context object used for drawing during the operation.
NSPrintOperation.h
Creates the graphics context object used for drawing during the operation.
- (NSGraphicsContext *)createContext
The graphics context object used for drawing. This object is created using the settings from the receiver's NSPrintInfo object.
Do not invoke this method directly—it is invoked before any output is generated.
NSPrintOperation.h
Returns the current page number being printed.
- (NSInteger)currentPage
The current page being printed.
NSPrintOperation.h
Delivers the results of the print operation to the intended destination.
- (BOOL)deliverResult
YES if the results were successfully delivered; otherwise, NO.
This method may be called to deliver the results to the printer spool or preview application. Do not invoke this method directly—it is invoked automatically when the print operation is done.
NSPrintOperation.h
Destroys the receiver’s graphics context.
- (void)destroyContext
Do not invoke this method directly—it is invoked at the end of a print operation.
NSPrintOperation.hReturns a Boolean value indicating whether the receiver is an EPS or PDF copy operation.
- (BOOL)isCopyingOperation
YES if the receiver is an EPS or PDF copy operation; otherwise, NO.
NSPrintOperation.hReturns the title of the print job.
- (NSString *)jobTitle
A string containing the print job title. If set, this value overrides the title returned by the printing view.
– setJobTitle:– printJobTitle (NSView)NSPrintOperation.hReturns the print order for the pages.
- (NSPrintingPageOrder)pageOrder
The print order. For a list of possible values, see “Constants.”
NSPrintOperation.hReturns the range of pages associated with the print operation.
- (NSRange)pageRange
The range of page numbers. Page numbers are one-based values where the index of page one is 1, the index of page two is 2, and so on. Depending on the information returned by the printing view, the starting page number may not be 1. Also, if the number of pages being printed is not known, the page count may be set to NSIntegerMax.
– knowsPageRange: (NSView)NSPrintOperation.hReturns the receiver’s NSPrintInfo object.
- (NSPrintInfo *)printInfo
The print settings of the receiver.
NSPrintOperation.h
Returns the NSPrintPanel object used when running the operation.
- (NSPrintPanel *)printPanel
The print panel object for the operation.
NSPrintOperation.hRuns the print operation on the current thread.
- (BOOL)runOperation
YES if the operation was successful; otherwise, NO.
The operation runs to completion in the current thread, blocking the application. A separate thread is not spawned, even if canSpawnSeparateThread is YES. Use runOperationModalForWindow:delegate:didRunSelector:contextInfo: to use document-modal sheets and to allow a separate thread to perform the operation.
NSPrintOperation.hRuns the print operation, calling your custom delegate method upon completion.
- (void)runOperationModalForWindow:(NSWindow *)docWindow delegate:(id)delegate didRunSelector:(SEL)didRunSelector contextInfo:(void *)contextInfo
The document window to receive a print progress sheet.
The printing delegate object. Messages are sent to this object.
The delegate method called after the completion of the print operation.
A pointer to any data you want passed to the method in the didRunSelector parameter.
The method specified by the didRunSelector parameter must have the following signature:
- (void)printOperationDidRun:(NSPrintOperation *)printOperation success:(BOOL)success contextInfo:(void *)contextInfo |
The value of success is YES if the print operation ran to completion without cancellation or error, and NO otherwise.
If you send setCanSpawnSeparateThread: to an NSPrintOperation object with an argument of YES, then the delegate specified in a subsequent invocation of runOperationModalForWindow:delegate:didRunSelector:contextInfo: may be messaged in that spawned, non-main thread.
NSPrintOperation.hSets whether the receiver is allowed to spawn a separate printing thread.
- (void)setCanSpawnSeparateThread:(BOOL)canSpawnSeparateThread
YES if the receiver is allowed to spawn a separate thread; otherwise, NO.
If canSpawnSeparateThread is YES, an NSThread object is detached when the print panel is dismissed (or immediately, if the panel is not to be displayed). The new thread performs the print operation, so that control can return to your application. A thread is detached only if the print operation is run using the runOperationModalForWindow:delegate:didRunSelector:contextInfo: method. If canSpawnSeparateThread is NO, the operation runs on the current thread, blocking the application until the operation completes.
If you send setCanSpawnSeparateThread: to an NSPrintOperation object with an argument of YES, then the delegate specified in a subsequent invocation of runOperationModalForWindow:delegate:didRunSelector:contextInfo: may be messaged in that spawned, non-main thread.
NSPrintOperation.hAssigns a custom title to the print job.
- (void)setJobTitle:(NSString *)jobTitle
The print job title. The receiver makes its own copy of the specified string.
Assigning a title with this method overrides the job title provided by the printing view’s printJobTitle method. Specifying nil for the jobTitle parameter causes the receiver to once again take its title from the printing view.
– jobTitle– printJobTitle (NSView)NSPrintOperation.hSets the print order for the pages of the operation.
- (void)setPageOrder:(NSPrintingPageOrder)order
The print order. For a list of possible values, see “Constants.”
NSPrintOperation.h
Sets the receiver’s NSPrintInfo object.
- (void)setPrintInfo:(NSPrintInfo *)aPrintInfo
The new print settings for the receiver.
NSPrintOperation.hSets the NSPrintPanel object to be used during the operation.
- (void)setPrintPanel:(NSPrintPanel *)panel
The print panel object to use for the operation.
NSPrintOperation.hSets whether the receiver displays a print panel for this operation.
- (void)setShowsPrintPanel:(BOOL)flag
YES if you want to display a print panel; otherwise, NO.
This method does not affect the display of a progress panel; that operation is controlled by the setShowsProgressPanel: method.
Operations that generate EPS or PDF data do no display a progress panel, regardless of the value in the flag parameter.
NSPrintOperation.hSets whether the receiver displays a progress panel for this operation.
- (void)setShowsProgressPanel:(BOOL)flag
YES if you want to display a progress panel; otherwise, NO.
This method does not affect the display of a print panel; that operation is controlled by the setShowsPrintPanel: method.
Operations that generate EPS or PDF data do no display a progress panel, regardless of the value in the flag parameter.
NSPrintOperation.hReturns a Boolean value indicating whether a print panel is displayed during the operation,
- (BOOL)showsPrintPanel
YES if the operation displays a print panel; otherwise, NO.
Operations that generate EPS or PDF data do no display a print panel (instance of NSPrintPanel), regardless of the value returned by this method.
NSPrintOperation.hReturns a Boolean value indicating whether a progress panel is displayed during the operation.
- (BOOL)showsProgressPanel
YES if the operation displays a progress panel; otherwise, NO.
Operations that generate EPS or PDF data do no display a progress panel, regardless of the value returned by this method.
NSPrintOperation.hReturns the view object that generates the actual data for the print operation.
- (NSView *)view
The view object that generates the data.
NSPrintOperation.hThese constants specify the page order.
typedef enum _NSPrintingPageOrder { NSDescendingPageOrder = (-1), NSSpecialPageOrder = 0, NSAscendingPageOrder = 1, NSUnknownPageOrder = 2 } NSPrintingPageOrder;
NSAscendingPageOrderAscending (back to front) page order.
Available in Mac OS X v10.0 and later.
Declared in NSPrintOperation.h
NSDescendingPageOrderDescending (front to back) page order.
Available in Mac OS X v10.0 and later.
Declared in NSPrintOperation.h
NSSpecialPageOrderThe spooler does not rearrange pages—they are printed in the order received by the spooler.
Available in Mac OS X v10.0 and later.
Declared in NSPrintOperation.h
NSUnknownPageOrderNo page order specified.
Available in Mac OS X v10.0 and later.
Declared in NSPrintOperation.h
These constants are used by pageOrder and setPageOrder:.
NSPrintOperation.hThis is the name of an exception that can be raised by NSPrintOperation.
NSString *NSPrintOperationExistsException;
NSPrintOperationExistsExceptionThe name of an exception raised when there is already a print operation in process.
The methods that raise this exception are the EPSOperation... and printOperation....
Available in Mac OS X v10.0 and later.
Declared in NSPrintOperation.h
NSPrintOperation.h
Last updated: 2007-03-02