Return to the Alphabetic Index
Return to the Class Browser
Return to the Picture Browser
Copyright (c) 1994 by NeXT Computer, Inc. All Rights
Reserved.
NSPrintInfo
Inherits From: NSObject
Conforms To: NSCoding, NSCopying
NSObject (NSObject)
Declared In: AppKit/NSPrintInfo.h
Class Description
An NSPrintInfo object stores information that's used during printing. 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, as set through the
setSharedPrintInfo: class method. The shared NSPrintInfo object is
returned through the sharedPrintInfo class method.
An NSPrintInfo object is used by the NSPrintOperations class to control
printing. If you create special instances of NSPrintInfo objects for a specific
printing task, you must ensure that either the application's shared NSPrintInfo
object is current, or you must instantiate an NSPrintOperations object using
one of its methods that explicitly designate an NSPrintInfo object.
Although you can set an NSPrintInfo's attributes through the methods it
provides, this is usually the task of other objects, notably the NSPageLayout
and NSPrintPanel objects. The NSView or NSWindow that's being printed may also
supercede some NSPrintInfo settings. In particular, a NSView or NSWindow can
supply the range of pages in the document and can provide its own pagination
mechanism through the knowsPagesFirst:last: and rect:forPage:
methods (see the documentation of these methods in the NSView class for
details).
If the printed NSView or NSWindow doesn't supply a pagination, the
NSPrintInfo's vertical and horizontal pagination constants are used to trigger
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 below. See the NSFont specification for a discussion of
points.
Creating and Initializing an NSPrintInfo Instance
- - (id)initWithDictionary:(NSDictionary *)aDict Initializes a
newly allocated NSPrintInfo object by assigning it the parameters specified in
aDict. This is the designated initializer for the class.
Managing the Shared NSPrintInfo Object
- + (void)setSharedPrintInfo:(NSPrintInfo *)printInfo Sets the
shared NSPrintInfo object to printInfo.
- + (NSPrintInfo *)sharedPrintInfo Returns the shared NSPrintInfo
object.
Managing the Printing Rectangle
- + (NSSize)sizeForPaperName:(NSString *)name Returns the size for
the specified type of paper. name identifies the type of paper, such as
Letter or Legal.
Paper names are implementation specific.
- - (float)bottomMargin Returns the height of the bottom margin.
- - (float)leftMargin Returns the width of the left margin.
- - (NSPrintingOrientation)orientation Returns whether the orientation is
Portrait or Landscape.
- - (NSString *)paperName Returns the paper type, such as
Letter or Legal.
Paper names are implementation specific.
- - (NSSize)paperSize Returns the size of the paper.
- - (float)rightMargin Returns the width of the right margin.
- - (void)setBottomMargin:(float)value Sets the bottom margin to
value.
- - (void)setLeftMargin:(float)value Sets the left margin to
value.
- - (void)setOrientation:(NSPrintingOrientation)mode Sets the
orientation as Portrait or Landscape.
- - (void)setPaperName:(NSString *)name Sets the paper type.
name identifies the type of paper, such as
Letter or Legal.
Paper names are implementation specific.
- - (void)setPaperSize:(NSSize)size Sets the width and height of
the paper.
- - (void)setRightMargin:(float)value Sets the right margin to
value.
- - (void)setTopMargin:(float)value Sets the top margin to
value.
- - (float)topMargin Returns the height of the top margin.
Pagination
- - (NSPrintingPaginationMode)horizontalPagination Returns the horizontal
pagination mode.
- - (void)setHorizontalPagination:(NSPrintingPaginationMode)mode
Sets the horizontal pagination mode.
- - (void)setVerticalPagination:(NSPrintingPaginationMode)mode
Sets the vertical pagination mode.
- - (NSPrintingPaginationMode)verticalPagination Returns the vertical
pagination mode.
Positioning the Image on the Page
- - (BOOL)isHorizontallyCentered Returns whether the image is centered
horizontally.
- - (BOOL)isVerticallyCentered Returns whether the image is centered
vertically.
- - (void)setHorizontallyCentered:(BOOL)flag Sets whether the image
is centered horizontally.
- - (void)setVerticallyCentered:(BOOL)flag Sets whether the image
is centered vertically.
Specifying the Printer
- + (NSPrinter *)defaultPrinter Returns the user's default printer.
- + (void)setDefaultPrinter:(NSPrinter *)printer Sets the user's
default printer.
- - (NSPrinter *)printer Returns the NSPrinter that's used for printing.
- - (void)setPrinter:(NSPrinter *)aPrinter Sets the printer that's
used in subsequent printing jobs.
Controlling Printing
- - (NSString *)jobDisposition Returns the action specified for the job:
printing, faxing, previewing, etc. See setJobDisposition:.
- - (void)setJobDisposition:(NSString *)disposition Sets the action
specified for the job. disposition can be one of NSPrintSpoolJob,
NSPrintFaxJob, NSPrintPreviewJob, NSPrintSaveJob, NSPrintCancelJob.
- - (void)setUpPrintOperationDefaultValues Allows the receiver to set any
attribute that hasn't been previously set.
Accessing the NSPrintInfo Object's Dictionary
- - (NSMutableDictionary *)dictionary Returns the NSPrintInfo object's
dictionary.