Next Page > Hide TOC

NSPrinter Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/AppKit.framework
Availability
Available in Mac OS X v10.0 and later.
Companion guide
Declared in
NSPrinter.h

Overview

An NSPrinter object describes a printer’s capabilities as defined in its PPD file. An NSPrinter object can be constructed by specifying either the printer name or the make and model of an available printer. You use a printer object to get information about printers, not to modify printer attributes or control a printing job.

Adopted Protocols

NSCoding
NSCopying

Tasks

Creating an NSPrinter

Getting General Printer Information

Getting Attributes

Getting Specific Information

Querying the Tables

Deprecated Methods

Class Methods

printerNames

Returns the names of all available printers.

+ (NSArray *)printerNames

Return Value

An array of NSString objects, each of which contains the name of an available printer.

Discussion

The user constructs the list of available printers using the Print Center application.

Availability
See Also
Declared In
NSPrinter.h

printerTypes

Returns descriptions of the makes and models of all available printers.

+ (NSArray *)printerTypes

Return Value

An array of NSString objects, each of which contains the make and model information for a supported printer.

Availability
See Also
Declared In
NSPrinter.h

printerWithName:

Creates and returns an NSPrinter object initialized with the specified printer name.

+ (NSPrinter *)printerWithName:(NSString *)name

Parameters
name

The name of the printer.

Return Value

An initialized NSPrinter object, or nil if the specified printer was not available.

Availability
See Also
Declared In
NSPrinter.h

printerWithType:

Creates and returns an NSPrinter object initialized to the first available printer with the specified make and model information.

+ (NSPrinter *)printerWithType:(NSString *)type

Parameters
type

A string describing the make and model information. You can get this string using the printerTypes method.

Return Value

An initialized NSPrinter object, or nil if the specified printer was not available.

Availability
See Also
Declared In
NSPrinter.h

Instance Methods

booleanForKey:inTable:

Returns the Boolean value associated with the specified key.

- (BOOL)booleanForKey:(NSString *)key inTable:(NSString *)table

Parameters
key

The key whose value you want.

table

The name of a table from the printer's PPD file.

Return Value

The Boolean value associated with the key. Returns NO if the key is not in the table or the receiver lacks a PPD file.

Availability
See Also
Declared In
NSPrinter.h

deviceDescription

Returns a dictionary of keys and values describing the device.

- (NSDictionary *)deviceDescription

Return Value

A dictionary of the device properties. See NSGraphics.h for possible keys. The only key guaranteed to exist is NSDeviceIsPrinter.

Availability
Declared In
NSPrinter.h

floatForKey:inTable:

Returns the floating-point value associated with the specified key.

- (float)floatForKey:(NSString *)key inTable:(NSString *)table

Parameters
key

The key whose value you want.

table

The name of a table from the printer's PPD file.

Return Value

The floating-point value. Returns 0.0 if the key is not in the table or the receiver lacks a PPD file.

Availability
See Also
Declared In
NSPrinter.h

intForKey:inTable:

Returns the integer value associated with the specified key.

- (int)intForKey:(NSString *)key inTable:(NSString *)table

Parameters
key

The key whose value you want.

table

The name of a table from the printer's PPD file.

Return Value

The integer value. Returns 0 if the key is not in the table or the receiver lacks a PPD file.

Availability
See Also
Declared In
NSPrinter.h

isKey:inTable:

Returns a Boolean value indicating whether the specified key is in the specified table.

- (BOOL)isKey:(NSString *)key inTable:(NSString *)table

Parameters
key

The key whose value you want.

table

The name of a table from the printer's PPD file.

Return Value

YES if the key is in the table; otherwise, NO.

Availability
Declared In
NSPrinter.h

languageLevel

Returns the PostScript language level recognized by the printer.

- (NSInteger)languageLevel

Return Value

The PostScript language level. The value is 0 if the receiver is not a PostScript printer.

Availability
Declared In
NSPrinter.h

name

Returns the printer’s name.

- (NSString *)name

Return Value

The printer name.

Availability
See Also
Declared In
NSPrinter.h

pageSizeForPaper:

Returns the size of the page for the specified paper type.

- (NSSize)pageSizeForPaper:(NSString *)paperName

Parameters
paperName

Possible values are printer-dependent and are contained in the printer's PPD file. Typical values are "Letter" and "Legal".

Return Value

The size of the page, measured in points in the user coordinate space. The returned size is zero if the specified paper name is not recognized or its entry in the PPD file cannot be parsed.

Availability
See Also
Declared In
NSPrinter.h

rectForKey:inTable:

Returns the rectangle associated with the specified key.

- (NSRect)rectForKey:(NSString *)key inTable:(NSString *)table

Parameters
key

The key whose value you want.

table

The name of a table from the printer's PPD file.

Return Value

The rectangle value. Returns NSZeroRect if the key is not in the table or the receiver lacks a PPD file.

Availability
See Also
Declared In
NSPrinter.h

sizeForKey:inTable:

Returns the size data type associated with the specified key.

- (NSSize)sizeForKey:(NSString *)key inTable:(NSString *)table

Parameters
key

The key whose value you want.

table

The name of a table from the printer's PPD file.

Return Value

The size value. Returns NSZeroSize if the key is not in the table or the receiver lacks a PPD file.

Availability
See Also
Declared In
NSPrinter.h

statusForTable:

Returns the status of the specified table.

- (NSPrinterTableStatus)statusForTable:(NSString *)table

Parameters
table

The name of a table from the printer's PPD file.

Return Value

One of the return values described in “Constants.”

Availability
Declared In
NSPrinter.h

stringForKey:inTable:

Returns the first occurrence of a value associated with specified key.

- (NSString *)stringForKey:(NSString *)key inTable:(NSString *)table

Parameters
key

The key whose value you want.

table

The name of a table from the printer's PPD file.

Return Value

The value for the specified key, or nil if the key is not in the table. The returned string may also be empty.

Discussion

If key is a main keyword only, and if that keyword has options in the PPD file, this method returns an empty string. Use stringListForKey:inTable: to retrieve the values for all occurrences of a main keyword.

Availability
See Also
Declared In
NSPrinter.h

stringListForKey:inTable:

Returns an array of strings, one for each occurrence, associated with specified key.

- (NSArray *)stringListForKey:(NSString *)key inTable:(NSString *)table

Parameters
key

The key whose value you want.

table

The name of a table from the printer's PPD file.

Return Value

An array of NSString objects, each containing a value associated with the specified key. Returns nil if the key is not in the table.

Availability
See Also
Declared In
NSPrinter.h

type

Returns a description of the printer’s make and model.

- (NSString *)type

Return Value

A description of the printer's make and model.

Availability
See Also
Declared In
NSPrinter.h

Constants

NSPrinterTableStatus

These constants describe the state of a printer information table stored by an NSPrinter object.

typedef enum _NSPrinterTableStatus {
   NSPrinterTableOK = 0,
   NSPrinterTableNotFound = 1,
   NSPrinterTableError = 2
} NSPrinterTableStatus;

Constants
NSPrinterTableOK

Printer table was found and is valid.

Available in Mac OS X v10.0 and later.

Declared in NSPrinter.h.

NSPrinterTableNotFound

Printer table was not found.

Available in Mac OS X v10.0 and later.

Declared in NSPrinter.h.

NSPrinterTableError

Printer table is not valid.

Available in Mac OS X v10.0 and later.

Declared in NSPrinter.h.

Discussion

These constants are used by statusForTable:..

Availability
Declared In
NSPrinter.h

Next Page > Hide TOC


© 2007 Apple Inc. All Rights Reserved. (Last updated: 2007-01-29)


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.