Next Page > Hide TOC

Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

NSPrintInfo

Inherits from
Implements
Package
com.apple.cocoa.application
Companion guide

Overview

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.

Tasks

Constructors

Managing the Shared NSPrintInfo

Managing the Printing Rectangle

Pagination

Positioning the Image on the Page

Specifying the Printer

Controlling Printing

Accessing the Dictionary

Deprecated Methods

Constructors

NSPrintInfo

Creates an empty NSPrintInfo.

public NSPrintInfo()

Creates a new NSPrintInfo object, assigning it the parameters specified in aDictionary.

public NSPrintInfo(NSDictionary aDictionary)

Discussion

The possible key-value pairs contained in aDictionary are described in “Constants.”

See Also

Static Methods

defaultPrinter

Deprecated.

public static NSPrinter defaultPrinter()

setDefaultPrinter

Deprecated.

public static void setDefaultPrinter(NSPrinter aPrinter)

setSharedPrintInfo

Sets the shared NSPrintInfo object to printInfo.

public static void setSharedPrintInfo(NSPrintInfo printInfo)

Discussion

The shared NSPrintInfo object defines the settings for the NSPageLayout panel and print operations that will be used if no NSPrintInfo object is specified for those operations. printInfo should never be null.

See Also

sharedPrintInfo

Returns the shared NSPrintInfo object.

public static NSPrintInfo sharedPrintInfo()

See Also

sizeForPaperName

Deprecated.

public static NSSize sizeForPaperName(String name)

Discussion

Use NSPrinter’s method pageSizeForPaper instead.

Instance Methods

bottomMargin

Returns the height of the bottom margin in points.

public float bottomMargin()

See Also

dictionary

Returns the receiver’s dictionary that stores its attribute settings

public NSMutableDictionary dictionary()

Discussion

. The key-value pairs contained in the dictionary are described in “Constants.” Modifying the returned dictionary changes the receiver’s attributes.

horizontalPagination

Returns the horizontal pagination mode.

public int horizontalPagination()

Discussion

It can return one of the pagination modes described in “Constants.”

See Also

imageablePageBounds

Returns the imageable area of a sheet of paper specified by the receiver, taking into account the current printer, paper size, and orientation settings, but not scaling.

public NSRect imageablePageBounds()

Discussion

“Imageable area” is the maximum area that can possibly be marked on by the printer hardware, not the area defined by the current margin settings. The rectangle is in a coordinate space measured by points, with (0, 0) being the lower-left corner of the oriented sheet and (paperWidth, paperHeight) being the upper-right corner of the oriented sheet. The imageable bounds may extend past the edges of the sheet when, for example, a printer driver specifies it so that borderless printing can be done reliably.

Availability

isHorizontallyCentered

Returns true if the image is centered horizontally, false otherwise.

public boolean isHorizontallyCentered()

See Also

isVerticallyCentered

Returns true if the image is centered vertically, false otherwise.

public boolean isVerticallyCentered()

See Also

jobDisposition

Returns the action specified for the job.

public String jobDisposition()

Discussion

See setJobDisposition for a description of return values.

leftMargin

Returns the width of the left margin in points.

public float leftMargin()

See Also

localizedPaperName

Returns the human-readable name of the currently selected paper size, suitable for presentation in user interfaces.

public String localizedPaperName()

Discussion

This is typically different from the name returned by paperName, which is almost never suitable for presentation to the user.

Availability

orientation

Returns the orientation attribute.

public int orientation()

Discussion

See setOrientation for a description of return values.

paperName

Returns the paper name, such as Letter or Legal.

public String paperName()

Discussion

Paper names are implementation specific.

See Also

paperSize

Returns the size of the paper in points.

public NSSize paperSize()

See Also

printer

Returns the NSPrinter to be used for printing.

public NSPrinter printer()

See Also

rightMargin

Returns the width of the right margin in points.

public float rightMargin()

See Also

setBottomMargin

Sets the bottom margin to margin specified in points.

public void setBottomMargin(float margin)

See Also

setHorizontallyCentered

public void setHorizontallyCentered(boolean flag)

Discussion

If flag is true the image will be centered horizontally.

See Also

setHorizontalPagination

Sets the horizontal pagination to mode.

public void setHorizontalPagination(int mode)

Discussion

mode can be one of the pagination modes described in “Constants.”

See Also

setJobDisposition

Sets the action specified for the job to disposition.

public void setJobDisposition(String disposition)

Discussion

disposition can be one of the following:

See Also

setLeftMargin

Sets the left margin to margin specified in points.

public void setLeftMargin(float margin)

See Also

setOrientation

Sets the page orientation to orientation where orientation is either PortraitOrientation or LandscapeOrientation.

public void setOrientation(int orientation)

Discussion

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

setPaperName

Sets the paper name to name (for example, Letter or Legal).

public void setPaperName(String name)

Discussion

Paper names are implementation specific. This method may change either the size or orientation for consistency. To avoid this side effect set the values in the dictionary directly.

See Also

setPaperSize

Sets the width and height of the paper to aSize specified in points.

public void setPaperSize(NSSize aSize)

Discussion

This method may change either the paper name or orientation for consistency. To avoid this side effect set the values in the dictionary directly.

See Also

setPrinter

Sets the printer used in subsequent printing jobs to printer.

public void setPrinter(NSPrinter printer)

Discussion

This method iterates through the dictionary. If a feature in the dictionary is not supported by the new printer (as determined by a query to the PPD file), that feature is removed from the dictionary.

See Also

setRightMargin

Sets the right margin to margin specified in points.

public void setRightMargin(float margin)

See Also

setTopMargin

Sets the top margin to margin specified in points.

public void setTopMargin(float margin)

See Also

setUpPrintOperationDefaultValues

Validates the attributes encapsulated by the receiver.

public void setUpPrintOperationDefaultValues()

Discussion

Invoked when the print operation is about to start. Subclasses may override this method to set default values for any attributes that are not set.

setVerticallyCentered

public void setVerticallyCentered(boolean flag)

Discussion

If flag is true, the image will be vertically centered.

See Also

setVerticalPagination

Sets the vertical pagination to mode.

public void setVerticalPagination(int mode)

Discussion

mode can be one of the pagination modes described in “Constants.”

See Also

topMargin

Returns the top margin in points.

public float topMargin()

See Also

verticalPagination

Returns the vertical pagination mode.

public int verticalPagination()

Discussion

It can return one of the pagination modes described in “Constants.”

See Also

Constants

These constants specify the different ways in which an image is divided into pages. They’re used by horizontalPagination, setHorizontalPagination, verticalPagination, and setVerticalPagination.

Pagination Constant

Meaning

AutoPagination

The image is divided into equal-sized rectangles and placed in one column of pages.

FitPagination

The image is scaled to produce one column or one row of pages.

ClipPagination

The image is clipped to produce one column or row of pages.

These constants specify page orientations. They’re used by orientation and setOrientation.

Orientation

Meaning

PortraitOrientation

Orientation is portrait (page is taller than it is wide).

LandscapeOrientation

Orientation is landscape (page is wider than it is tall).

These constants specify job dispositions. They’re used by jobDisposition, and setJobDisposition.

Mode

Meaning

PrintSpoolJob

Normal print job.

PrintPreviewJob

Send to Preview application.

PrintSaveJob

Save to a file.

PrintCancelJob

Cancel print job.

The following sets of constants specify the keys in the dictionary returned by dictionary or used to create an instance.

The following dictionary keys access page setup attributes.

Constant

Type

Description

PrintPaperName

String

The paper name.

PrintPaperSize

NSSize

Height and width of paper in points.

PrintOrientation

int

PortraitOrientation or LandscapeOrientation

PrintScalingFactor

float

Scale factor percentage before pagination.

The following dictionary keys access pagination attributes.

Constant

Type

Description

PrintLeftMargin

float

The left margin in points.

PrintRightMargin

float

The right margin in points.

PrintTopMargin

float

The top margin in points.

PrintBottomMargin

float

The bottom margin in points.

PrintHorizontallyCentered

boolean

If true, pages are centered horizontally.

PrintVerticallyCentered

boolean

If true, pages are centered vertically.

PrintHorizontalPagination

int

AutoPagination, FitPagination, or ClipPagination. See setHorizontalPagination for details.

PrintVerticalPagination

int

AutoPagination, FitPagination, or ClipPagination. See setVerticalPagination for details.

The following dictionary keys access print job attributes.

Constant

Type

Description

PrintPrinter

NSPrinter

The printer to use.

PrintCopies

int

Number of copies to spool.

PrintAllPages

boolean

If true, includes all pages in output.

PrintFirstPage

int

The first page in the print job.

PrintLastPage

int

The last page in the print job.

PrintReversePageOrder

boolean

If true, prints last page first.

PrintMustCollate

boolean

If true, collates output.

PrintJobDisposition

String

PrintSpoolJob, PrintPreviewJob, PrintSaveJob, or PrintCancelJob. See setJobDisposition for details.

PrintSavePath

String

Pathname to save as a file if job disposition is PrintSaveJob.

PrintPagesAcross

Number

The number of logical pages to be tiled horizontally on a physical sheet of paper. (Available in Mac OS X v10.4 and later.)

PrintPagesDown

Number

The number of logical pages to be tiled veritcally on a physical sheet of paper. (Available in Mac OS X v10.4 and later.)

PrintTime

Date

The time at which printing should begin. (Available in Mac OS X v10.4 and later.)

PrintDetailedErrorReporting

Number, containing aboolean

If true, produce detailed reports when an error occurs. (Available in Mac OS X v10.4 and later.)

PrintFaxNumber

String

A fax number. (Available in Mac OS X v10.4 and later.)

PrintPrinterName

String

The name of a printer. (Available in Mac OS X v10.4 and later.)



Next Page > Hide TOC


© 1997, 2007 Apple Inc. All Rights Reserved. (Last updated: 2007-02-01)


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.