- Inherits from:
- NSObject
- Conforms to:
- NSCoding
- NSCopying
- NSObject (NSObject)
Declared in:
- AppKit/NSPrintInfo.h
An NSPrintInfo object stores information that's used to generate output. A shared NSPrintInfo object is automatically created for an application and is used by default for all printing jobs for that application. You can create any number of additional NSPrintInfo objects; however, only one can be "active" at a time, set using the setSharedPrintInfo: class method. You get the shared NSPrintInfo object using the sharedPrintInfo class method.
An NSPrintInfo object is used by NSPrintOperation objects to control printing (it is passed to a NSPrintOperation object which makes a copy of it to use during an operation). If you create special instances of NSPrintInfo objects for a specific printing task, you must ensure that your NSPrintInfo object is the shared one, or instantiate an NSPrintOperation object specifying your NSPrintInfo object.
Normally you don't set NSPrintInfo attributes directly-this is done by instances of NSPageLayout and NSPrintPanel. The NSView that's being printed may also supercede some NSPrintInfo settings. In particular, an NSView can supply the range of pages in the document and can provide its own pagination mechanism through the knowsPageRange: and rectForPage: methods (see the documentation of these methods in the NSView class for details).
If the NSView doesn't supply pagination information, the NSPrintInfo's vertical and horizontal pagination constants are used to trigger these built-in pagination mechanisms:
Pagination Constant | Meaning |
NSAutoPagination |
The image is diced into equal-sized rectangles and placed in one column of pages. |
NSFitPagination |
The image is scaled to produce one column or one row of pages. |
NSClipPagination |
The image is clipped to produce one column or row of pages. |
Vertical and horizontal pagination needn't be the same.
However, if either dimension is scaled (NSFitPagination
),
the other dimension is scaled by the same amount to avoid stretching
the image. If both dimensions are scaled, the scaling factor that
produces the smallest image is used. Note that NSPrintInfo's scaling
factor is independent of the scaling that's imposed by pagination
and is applied after the document has been paginated.
NSPrintInfo uses points as the unit of measurement for paper size and margin width in the methods described below. See the NSFont specification for a discussion of points.
An NSPrinterInfo contains a dictionary that stores its attribute settings. These are the keys that allow you to access the appropriate value contained in the dictionary:
Key | Type | Description |
NSPrintPaperName |
NSString | The paper name. |
NSPrintPaperSize |
NSSize | Height and width of paper in points. |
NSPrintMustCollate |
BOOL | If YES, collates output. |
NSPrintFormName |
NSString | Form name such as "Letter" or "Letter Small". |
NSPrintOrientation |
NSPrintingOrientation | NSPortraitOrientation or NSLandscapeOrientation |
NSPrintLeftMargin |
float | The left margin in points. |
NSPrintRightmargin |
float | The right margin in points. |
NSPrintTopMargin |
float | The top margin in points. |
NSPrintBottomMargin |
float | The bottom margin in points. |
NSPrintHorizontallyCentered |
BOOL | If YES, pages are centered horizontally. |
NSPrintVerticallyCentered |
BOOL | If YES, pages are centered vertically. |
NSPrintHorizontalPagination |
NSPrintingPaginationMode | NSAutoPagination , NSFitPagination ,
or NSClipPagination . See setHorizontalPagination: for details. |
NSPrintVerticalPagination |
NSPrintingPaginationMode | NSAutoPagination , NSFitPagination ,
or NSClipPagination . See setVerticalPagination: for
details. |
NSPrintScalingFactor |
float | Scale factor before pagination. |
NSPrintAllPages |
BOOL | If YES, includes all pages in output. |
NSPrintReversePageOrder |
BOOL | If YES, prints last page first. |
NSPrintFirstPage |
int | The first page in the print job. |
NSPrintLastPage |
int | The last page in the print job. |
NSPrintCopies |
int | Number of copies to spool. |
NSPrintPagesPerSheet |
int | The number of pages of the document that are printed on a single sheet of paper. This number is rounded up to the power of two when used by the system. |
NSPrintJobFeatures |
NSMutableDictionary | Features from the NSPrinter object where keys are the
feature name and values are the settings. For example, the key NSPrintPaperFeed might have
the value *InputSlot/Upper. See the NSPrinter class description. |
NSPrintPaperFeed |
NSString | The printer slot. For example, InputSlot/Upper or NSPrintManualFeed . |
NSPrintPrinter |
NSPrinter | The printer to use. |
NSPrintJobDisposition |
NSString | NSPrintSpoolJob , NSPrintFaxJob , NSPrintPreviewJob , NSPrintSaveJob ,
or NSPrintCancelJob . See setJobDisposition: for
details. |
NSPrintSavePath |
NSString | Pathname to save as a file if job disposition is NSPrintSaveJob . |
NSPrintFaxReceiverNames |
NSArray | Array of NSStrings containing receiver names for a fax job. |
NSPrintFaxReceiverNumbers |
NSArray | Array of NSStrings containing the receiver phone numbers for a fax job. |
NSPrintFaxSendTime |
NSDate | When to send the fax. |
NSPrintFaxUseCoverSheet |
BOOL | If YES, send cover sheet. |
NSPrintFaxCoverSheetName |
NSString | The filename containing the cover sheet. |
NSPrintFaxReturnReceipt |
BOOL | If YES, sends confirmation email when fax is sent. |
NSPrintFaxHighResolution |
BOOL | If YES, sends fax at high resolution. |
NSPrintFaxTrimPageEnds |
BOOL | If YES, trims page ends, otherwise sends complete pages. |
NSPrintFaxModem |
NSPrinter | The fax modem to use. |
These constants specify pagination modes. They're used by horizontalPagination, setHorizontalPagination:, verticalPagination, and setVerticalPagination:.
Pagination Constant | Meaning |
NSAutoPagination |
The image is diced into equal-sized rectangles and placed in one column of pages. |
NSFitPagination |
The image is scaled to produce one column or one row of pages. |
NSClipPagination |
The image is clipped to produce one column or row of pages. |
These constants specify page orientations. They're used by orientation, and setOrientation:.
Mode | Meaning |
NSPortraitOrientation |
Description forthcoming. |
NSLandscapeOrientation |
Description forthcoming. |
NSCoding
- - encodeWithCoder:
- - initWithCoder:
NSCopying
- - copyWithZone:
- Initializing an NSPrintInfo
- - initWithDictionary:
- Managing the shared NSPrintInfo
- + setSharedPrintInfo:
- + sharedPrintInfo
- Managing the printing rectangle
- + sizeForPaperName:
- - bottomMargin
- - leftMargin
- - orientation
- - paperName
- - paperSize
- - rightMargin
- - setBottomMargin:
- - setLeftMargin:
- - setOrientation:
- - setPaperName:
- - setPaperSize:
- - setRightMargin:
- - setTopMargin:
- - topMargin
- Pagination
- - horizontalPagination
- - setHorizontalPagination:
- - setVerticalPagination:
- - verticalPagination
- Positioning the image on the page
- - isHorizontallyCentered
- - isVerticallyCentered
- - setHorizontallyCentered:
- - setVerticallyCentered:
- Specifying the printer
- + defaultPrinter
- + setDefaultPrinter:
- - printer
- - setPrinter:
- Controlling printing
- - jobDisposition
- - setJobDisposition:
- - setUpPrintOperationDefaultValues
- Accessing the dictionary
- - dictionary
+ (NSPrinter *)defaultPrinter
nil
if
the printer cannot be found.See Also: + setDefaultPrinter:
+ (void)setDefaultPrinter:(NSPrinter
*)aPrinter
See Also: + defaultPrinter, - printer
+ (void)setSharedPrintInfo:(NSPrintInfo
*)printInfo
nil
.See Also: + sharedPrintInfo
+ (NSPrintInfo *)sharedPrintInfo
See Also: + setSharedPrintInfo:
+ (NSSize)sizeForPaperName:(NSString
*)name
- (float)bottomMargin
See Also: - setBottomMargin:
- (NSMutableDictionary *)dictionary
- (NSPrintingPaginationMode)horizontalPagination
See Also: - setVerticalPagination:, - verticalPagination
- (id)initWithDictionary:(NSDictionary
*)aDictionary
See Also: - dictionary
- (BOOL)isHorizontallyCentered
YES
if
the image is centered horizontally, NO
otherwise.See Also: - isVerticallyCentered, - setHorizontallyCentered:
- (BOOL)isVerticallyCentered
YES
if
the image is centered vertically, NO
otherwise.See Also: - isHorizontallyCentered, - setVerticallyCentered:
- (NSString *)jobDisposition
- (float)leftMargin
See Also: - setLeftMargin:
- (NSPrintingOrientation)orientation
- (NSString *)paperName
See Also: - setPaperName:
- (NSSize)paperSize
See Also: - setPaperSize:
- (NSPrinter *)printer
See Also: - setPrinter:
- (float)rightMargin
See Also: - setRightMargin:
- (void)setBottomMargin:(float)margin
See Also: - bottomMargin
- (void)setHorizontalPagination:(NSPrintingPaginationMode)mode
See Also: - horizontalPagination, - setVerticalPagination:, - verticalPagination
- (void)setHorizontallyCentered:(BOOL)flag
YES
the
image will be centered horizontally.See Also: - isHorizontallyCentered, - isVerticallyCentered, - setVerticallyCentered:
- (void)setJobDisposition:(NSString
*)disposition
Disposition | Meaning |
NSPrintSpoolJob |
Normal print job. |
NSPrintFaxJob |
Fax job. |
NSPrintPreviewJob |
Send to Preview application. |
NSPrintSaveJob |
Save to a file. |
NSPrintCancelJob |
Cancel print job. |
See Also: - jobDisposition
- (void)setLeftMargin:(float)margin
See Also: - leftMargin
- (void)setOrientation:(NSPrintingOrientation)orientation
NSPortraitOrientation
or NSLandscapeOrientation
. This
method may change either the paper name or size for consistency.
To avoid this side effect set the values in the dictionary directly.See Also: - dictionary, - initWithDictionary:, - orientation
- (void)setPaperName:(NSString
*)name
See Also: - dictionary, - initWithDictionary:, - paperName
- (void)setPaperSize:(NSSize)aSize
See Also: - dictionary, - initWithDictionary:, - paperSize
- (void)setPrinter:(NSPrinter
*)aPrinter
See Also: - printer
- (void)setRightMargin:(float)margin
See Also: - rightMargin
- (void)setTopMargin:(float)margin
See Also: - topMargin
- (void)setUpPrintOperationDefaultValues
- (void)setVerticalPagination:(NSPrintingPaginationMode)mode
See Also: - horizontalPagination, - setHorizontalPagination:, - verticalPagination
- (void)setVerticallyCentered:(BOOL)flag
YES
,
the image will be vertically centered.See Also: - isHorizontallyCentered, - isVerticallyCentered, - setHorizontallyCentered:
- (float)topMargin
See Also: - setTopMargin:
- (NSPrintingPaginationMode)verticalPagination
See Also: - horizontalPagination, - setHorizontalPagination: