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
Tasks
Creating an NSPrinter
Getting General Printer Information
Getting Attributes
Getting Specific Information
Querying the Tables
-
– isKey:inTable: -
– stringForKey:inTable: -
– stringListForKey:inTable: -
– booleanForKey:inTable: -
– floatForKey:inTable: -
– intForKey:inTable: -
– rectForKey:inTable: -
– sizeForKey:inTable: -
– statusForTable: -
– deviceDescription
Deprecated Methods
-
+ printerWithName:domain:includeUnavailable:Deprecated in OS X v10.2 -
– acceptsBinaryDeprecated in OS X v10.2 -
– domainDeprecated in OS X v10.2 -
– hostDeprecated in OS X v10.2 -
– imageRectForPaper:Deprecated in OS X v10.2 -
– isColorDeprecated in OS X v10.2 -
– isFontAvailable:Deprecated in OS X v10.2 -
– isOutputStackInReverseOrderDeprecated in OS X v10.2 -
– noteDeprecated in OS X v10.2
Class Methods
printerNames
Returns the names of all available printers.
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.
See Also
Declared In
NSPrinter.hprinterTypes
Returns descriptions of the makes and models of all available printers.
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.hprinterWithName:
Creates and returns an NSPrinter object initialized with the specified printer 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.
See Also
Declared In
NSPrinter.hprinterWithType:
Creates and returns an NSPrinter object initialized to the first available printer with the specified make and model information.
Parameters
- type
A string describing the make and model information. You can get this string using the
printerTypesmethod.
Return Value
An initialized NSPrinter object, or nil if the specified printer was not available.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSPrinter.hInstance Methods
booleanForKey:inTable:
Returns the Boolean value associated with the specified key.
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
- Available in OS X v10.0 and later.
See Also
Declared In
NSPrinter.hdeviceDescription
Returns a dictionary of keys and values describing the device.
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.hfloatForKey:inTable:
Returns the floating-point value associated with the specified key.
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
- Available in OS X v10.0 and later.
See Also
Declared In
NSPrinter.hintForKey:inTable:
Returns the integer value associated with the specified key.
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
- Available in OS X v10.0 and later.
See Also
Declared In
NSPrinter.hisKey:inTable:
Returns a Boolean value indicating whether the specified key is in the specified 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
- Available in OS X v10.0 and later.
Declared In
NSPrinter.hlanguageLevel
Returns the PostScript language level recognized by the printer.
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.hname
Returns the printer’s name.
Return Value
The printer name.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSPrinter.hpageSizeForPaper:
Returns the size of the page for the specified paper type.
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.
See Also
Declared In
NSPrinter.hrectForKey:inTable:
Returns the rectangle associated with the specified key.
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
- Available in OS X v10.0 and later.
See Also
Declared In
NSPrinter.hsizeForKey:inTable:
Returns the size data type associated with the specified key.
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
- Available in OS X v10.0 and later.
See Also
Declared In
NSPrinter.hstatusForTable:
Returns the status of the specified 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
- Available in OS X v10.0 and later.
Declared In
NSPrinter.hstringForKey:inTable:
Returns the first occurrence of a value associated with specified key.
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
- Available in OS X v10.0 and later.
See Also
Declared In
NSPrinter.hstringListForKey:inTable:
Returns an array of strings, one for each occurrence, associated with specified key.
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
- Available in OS X v10.0 and later.
See Also
Declared In
NSPrinter.htype
Returns a description of the printer’s make and model.
Return Value
A description of the printer's make and model.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSPrinter.hConstants
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
NSPrinterTableOKPrinter table was found and is valid.
Available in OS X v10.0 and later.
Declared in
NSPrinter.h.NSPrinterTableNotFoundPrinter table was not found.
Available in OS X v10.0 and later.
Declared in
NSPrinter.h.NSPrinterTableErrorPrinter 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© 2012 Apple Inc. All Rights Reserved. (Last updated: 2012-09-19)