NSPrinter Class Reference

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

Overview

An NSPrinter object describes a printer’s capabilities. It provides information about a printer; it does not modify printer attributes or control a printing job. An NSPrinter object can be constructed by specifying either the printer name or the make and model of an available printer.

It is not typical for Cocoa apps to create NSPrinter objects. The printing system uses these objects to support the printing jobs and when it shows users a list of printers.

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 when adding a printer in the Print panel or setting up printers in the Print & Scan preferences pane.

Availability
  • Available in OS X v10.0 and later.
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
  • Available in OS X v10.0 and later.
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
  • Available in OS X v10.0 and later.
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
  • Available in OS X v10.0 and later.
Declared In
NSPrinter.h

Instance Methods

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
  • Available in OS X v10.0 and later.
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
  • Available in OS X v10.0 and later.
Declared In
NSPrinter.h

name

Returns the printer’s name.

- (NSString *)name
Return Value

The printer name.

Availability
  • Available in OS X v10.0 and later.
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
  • Available in OS X v10.0 and later.
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
  • Available in OS X v10.0 and later.
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 OS X v10.0 and later.

Declared in NSPrinter.h.

NSPrinterTableNotFound

Printer table was not found.

Available in OS X v10.0 and later.

Declared in NSPrinter.h.

NSPrinterTableError

Printer table is not valid.

Available in OS X v10.0 and later.

Declared in NSPrinter.h.

Discussion

These constants are used by statusForTable:..

Availability
  • Available in OS X v10.0 and later.
Declared In
NSPrinter.h