- Inherits from:
- NSObject
- Conforms to:
- NSObject
- (NSObject)
Declared in:
- AppKit/NSPrintOperation.h
An NSPrintOperation object controls operations that generate Encapsulated PostScript (EPS) code or PostScript print jobs. Generally, EPS code is used to transfer images between applications, which happens when the user copies and pastes graphics, uses a Service, or uses ObjectLinks. PostScript is generated when the user prints and faxes documents. An NSPrintOperation object does not generate PostScript code itself; it just controls the overall process, relying on an NSView object to generate the actual code.
NSPrintOperation works in conjunction with two other objects: an NSPrintInfo object, which specifies how the code should be generated, and an NSView object, which performs the actual code generation. You specify these two objects in the method you use to create an NSPrintOperation object. If no NSPrintInfo is specified, NSPrintOperation uses the shared NSPrintInfo, which contains default values. (A shared NSPrintInfo object is automatically created for an application.) The shared NSPrintInfo works well for applications that are not document-based. However, document-based applications should create an NSPrintInfo for each document that might be printed or copied and use that object instead. This will allow users to set printing attributes on a per-document basis.
You create NSPrintOperation objects in any method that is invoked when a user chooses a Print or Copy command. That method must also send runOperation to the NSPrintOperation object to start the actual operation. For example, applications that are not document-based have a simple print: method as in:
- (void)print:sender { [[NSPrintOperation printOperationWithView:self] runOperation]; }
However, document-based applications should use their own instances of NSPrintInfo as in:
- (void)print:sender { [[NSPrintOperation printOperationWithView:[self myView] printInfo:[document docPrintInfo]] runOperation]; }
This method creates an NSPrintOperation for a print job that uses the document's NSPrintInfo object-not the shared NSPrintInfo object.
In both examples, because this is a print job, the NSPrintOperation object will display an NSPrintPanel object allowing the user to select printing options (i.e., number of pages to print and range of pages to print). The NSPrintOperation object copies the NSPrintInfo object, updates this copy with information from the NSPrintPanel object, and uses the specified NSView to perform the operation. Some of the information stored in an NSPrintInfo object is constant for a particular document, such as its page size. Other information that is likely to change between print operations is set to default values before the operation begins. In this way, even though NSPrintOperation updates the NSPrintInfo with information from the NSPrintPanel for a specific print job, that information is reset back to the default values for each print job. Because NSPrintOperation keeps a copy of the NSPrintInfo it uses, you could duplicate a specific print job by storing and reusing that copy.
When repeating a print job, you can suppress the display of
the NSPrintPanel object by sending setShowPanels:, passing NO
as
the argument, to the NSPrintOperation object before sending it runOperation. However,
make sure that any non-default settings in the NSPrintInfo object
that would normally be selected from a NSPrintPanel object are set
to reasonable values-a copy of an NSPrintInfo object used in a
previous print job will have the correct values.
You can also customize the NSPrintPanel object using the setAccessoryView: method or specify your own NSPrintPanel object using setPrintPanel: .
These constants specify the page order. They're used by pageOrder and setPageOrder:.
Order | Meaning |
NSAscendingPageOrder |
Ascending (back to front) page order. |
NSDescendingPageOrder |
Descending (front to back) page order. |
NSSpecialPageOrder |
The spooler will not rearrange pages-they are print in the order received by the spooler. |
NSUnknownPageOrder |
No page order specified. |
- Creating an NSPrintOperation
- + 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:
- Setting the current NSPrintOperation for this thread
- + currentOperation
- + setCurrentOperation:
- Determining the type of operation
- - isCopyingOperation
- Modifying the NSPrintInfo object
- - printInfo
- - setPrintInfo:
- Getting the NSView object
- - view
- Running a print operation
- - runOperation
- - cleanUpOperation
- - deliverResult
- Modifying the user interface
- - showPanels
- - setShowPanels:
- - accessoryView
- - setAccessoryView:
- - printPanel
- - setPrintPanel:
- Managing the DPS context
- - context
- - createContext
- - destroyContext
- Modifying page information
- - currentPage
- - pageOrder
- - setPageOrder:
+ (NSPrintOperation *)EPSOperationWithView:(NSView
*)aView
insideRect:(NSRect)rect
toData:(NSMutableData *)data
See Also: + EPSOperationWithView:insideRect:toData:printInfo:, + EPSOperationWithView:insideRect:toPath:printInfo:
+ (NSPrintOperation *)EPSOperationWithView:(NSView
*)aView
insideRect:(NSRect)rect
toData:(NSMutableData *)data
printInfo:(NSPrintInfo *)aPrintInfo
See Also: + EPSOperationWithView:insideRect:toData:, + EPSOperationWithView:insideRect:toPath:printInfo:
+ (NSPrintOperation *)EPSOperationWithView:(NSView
*)aView
insideRect:(NSRect)rect
toPath:(NSString *)path
printInfo:(NSPrintInfo *)aPrintInfo
See Also: + EPSOperationWithView:insideRect:toData:, + EPSOperationWithView:insideRect:toData:printInfo:
+ (NSPrintOperation *)PDFOperationWithView:(NSView
*)aView
insideRect:(NSRect)rect
toData:(NSMutableData *)data
See Also: + PDFOperationWithView:insideRect:toData:printInfo:, + PDFOperationWithView:insideRect:toPath:printInfo:
+ (NSPrintOperation *)PDFOperationWithView:(NSView
*)aView
insideRect:(NSRect)rect
toData:(NSMutableData *)data
printInfo:(NSPrintInfo *)aPrintInfo
See Also: + PDFOperationWithView:insideRect:toData:, + PDFOperationWithView:insideRect:toPath:printInfo:
+ (NSPrintOperation *)PDFOperationWithView:(NSView
*)aView
insideRect:(NSRect)rect
toPath:(NSString *)path
printInfo:(NSPrintInfo *)aPrintInfo
See Also: + PDFOperationWithView:insideRect:toData:, + PDFOperationWithView:insideRect:toData:printInfo:
+ (NSPrintOperation *)currentOperation
nil
if
there isn't a current operation.See Also: + setCurrentOperation:
+ (NSPrintOperation *)printOperationWithView:(NSView
*)aView
See Also: + printOperationWithView:printInfo:
+ (NSPrintOperation *)printOperationWithView:(NSView
*)aView
printInfo:(NSPrintInfo *)aPrintInfo
See Also: + printOperationWithView:
+ (void)setCurrentOperation:(NSPrintOperation
*)operation
nil
,
then there is no current print operation.See Also: + currentOperation
- (NSView *)accessoryView
See Also: - printPanel, - setPrintPanel:, - setShowPanels:, - showPanels
- (void)cleanUpOperation
- (NSGraphicsContext *)context
See Also: - createContext, - destroyContext
- (NSGraphicsContext *)createContext
See Also: - context, - destroyContext
- (int)currentPage
See Also: - pageOrder, - setPageOrder:
- (BOOL)deliverResult
YES
if
the operation was successful, NO
otherwise.
Do not invoke this method directly-it's invoked automatically
when the operation is done generating the output.- (void)destroyContext
See Also: - context, - createContext
- (BOOL)isCopyingOperation
- (NSPrintingPageOrder)pageOrder
See Also: - currentPage
- (NSPrintInfo *)printInfo
See Also: - setPrintInfo:
- (NSPrintPanel *)printPanel
See Also: - accessoryView, - setAccessoryView:, - setPrintPanel:, - setShowPanels:, - showPanels
- (BOOL)runOperation
YES
if
successful, NO
otherwise.See Also: - cleanUpOperation, - deliverResult
- (void)setAccessoryView:(NSView
*)aView
See Also: - accessoryView, - printPanel, - setPrintPanel:, - setShowPanels:, - showPanels
- (void)setPageOrder:(NSPrintingPageOrder)order
See Also: - currentPage, - pageOrder
- (void)setPrintInfo:(NSPrintInfo
*)aPrintInfo
See Also: - printInfo
- (void)setPrintPanel:(NSPrintPanel
*)panel
See Also: - accessoryView, - printPanel, - setAccessoryView:, - setShowPanels:, - showPanels
- (void)setShowPanels:(BOOL)flag
YES
then
the NSPrintPanel will be used in the operation, otherwise it will
not.See Also: - accessoryView, - printPanel, - setAccessoryView:, - setPrintPanel:, - showPanels
- (BOOL)showPanels
YES
if
the NSPrintPanel will be used in the operation, otherwise NO
.See Also: - accessoryView, - printPanel, - setAccessoryView:, - setPrintPanel:, - setShowPanels:
- (NSView *)view