Mac Developer Library

Developer

AppKit Framework Reference NSPrinter Class Reference

Options
Deployment Target:

On This Page
Language:

NSPrinter

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.

Inheritance


Conforms To


Import Statement


Swift

import AppKit

Objective-C

@import AppKit;

Availability


Available in OS X v10.0 and later.
  • Creates and returns an NSPrinter object initialized with the specified printer name.

    Declaration

    Swift

    init?(name name: String) -> NSPrinter

    Objective-C

    + (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.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

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

    Declaration

    Swift

    init?(type type: String) -> NSPrinter

    Objective-C

    + (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.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the names of all available printers.

    Declaration

    Swift

    class func printerNames() -> [AnyObject]

    Objective-C

    + (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.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

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

    Declaration

    Swift

    class func printerTypes() -> [AnyObject]

    Objective-C

    + (NSArray *)printerTypes

    Return Value

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

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    – type

  • Returns the printer’s name.

    Declaration

    Swift

    var name: String { get }

    Objective-C

    @property(readonly, copy) NSString *name

    Return Value

    The printer name.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

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

    Declaration

    Swift

    var type: String { get }

    Objective-C

    @property(readonly, copy) NSString *type

    Return Value

    A description of the printer's make and model.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    + printerTypes

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

    Declaration

    Swift

    func pageSizeForPaper(_ paperName: String) -> NSSize

    Objective-C

    - (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.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the PostScript language level recognized by the printer.

    Declaration

    Swift

    var languageLevel: Int { get }

    Objective-C

    @property(readonly) NSInteger languageLevel

    Return Value

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

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

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

    Declaration

    Objective-C

    - (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

    YEStrue if the key is in the table; otherwise, NOfalse.

    Import Statement

    Objective-C

    @import AppKit;

    Availability

    Available in OS X v10.0 and later.

    Deprecated in OS X v10.9.

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

    Declaration

    Objective-C

    - (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.

    Import Statement

    Objective-C

    @import AppKit;

    Availability

    Available in OS X v10.0 and later.

    Deprecated in OS X v10.9.

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

    Declaration

    Objective-C

    - (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.

    Import Statement

    Objective-C

    @import AppKit;

    Availability

    Available in OS X v10.0 and later.

    Deprecated in OS X v10.9.

  • Returns the Boolean value associated with the specified key.

    Declaration

    Objective-C

    - (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 NOfalse if the key is not in the table or the receiver lacks a PPD file.

    Import Statement

    Objective-C

    @import AppKit;

    Availability

    Available in OS X v10.0 and later.

    Deprecated in OS X v10.9.

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

    Declaration

    Objective-C

    - (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.

    Import Statement

    Objective-C

    @import AppKit;

    Availability

    Available in OS X v10.0 and later.

    Deprecated in OS X v10.9.

  • Returns the integer value associated with the specified key.

    Declaration

    Objective-C

    - (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.

    Import Statement

    Objective-C

    @import AppKit;

    Availability

    Available in OS X v10.0 and later.

    Deprecated in OS X v10.9.

  • Returns the rectangle associated with the specified key.

    Declaration

    Objective-C

    - (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.

    Import Statement

    Objective-C

    @import AppKit;

    Availability

    Available in OS X v10.0 and later.

    Deprecated in OS X v10.9.

  • Returns the size data type associated with the specified key.

    Declaration

    Objective-C

    - (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.

    Import Statement

    Objective-C

    @import AppKit;

    Availability

    Available in OS X v10.0 and later.

    Deprecated in OS X v10.9.

  • Returns the status of the specified table.

    Declaration

    Objective-C

    - (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.

    Import Statement

    Objective-C

    @import AppKit;

    Availability

    Available in OS X v10.0 and later.

    Deprecated in OS X v10.9.

  • Returns a dictionary of keys and values describing the device.

    Declaration

    Swift

    var deviceDescription: [NSObject : AnyObject] { get }

    Objective-C

    @property(readonly, copy) NSDictionary *deviceDescription

    Return Value

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

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Deprecated.

    Declaration

    Swift

    init?(name name: String, domain domain: String?, includeUnavailable flag: Bool) -> NSPrinter

    Objective-C

    + (NSPrinter *)printerWithName:(NSString *)name domain:(NSString *)domain includeUnavailable:(BOOL)flag

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    Deprecated in OS X v10.2.

  • Deprecated.

    Declaration

    Objective-C

    - (BOOL)acceptsBinary

    Import Statement

    Objective-C

    @import AppKit;

    Availability

    Available in OS X v10.0 and later.

    Deprecated in OS X v10.2.

  • domain - domain (OS X v10.2)

    Deprecated.

    Declaration

    Objective-C

    - (NSString *)domain

    Import Statement

    Objective-C

    @import AppKit;

    Availability

    Available in OS X v10.0 and later.

    Deprecated in OS X v10.2.

  • host - host (OS X v10.2)

    Deprecated.

    Declaration

    Objective-C

    - (NSString *)host

    Import Statement

    Objective-C

    @import AppKit;

    Availability

    Available in OS X v10.0 and later.

    Deprecated in OS X v10.2.

  • Deprecated.

    Declaration

    Objective-C

    - (NSRect)imageRectForPaper:(NSString *)paperName

    Discussion

    If used, it attempts to determine and return the bounds of the imageable area for a particular paper named paperName, but the result is not completely reliable.

    Import Statement

    Objective-C

    @import AppKit;

    Availability

    Available in OS X v10.0 and later.

    Deprecated in OS X v10.2.

  • isColor - isColor (OS X v10.2)

    Deprecated.

    Declaration

    Objective-C

    - (BOOL)isColor

    Import Statement

    Objective-C

    @import AppKit;

    Availability

    Available in OS X v10.0 and later.

    Deprecated in OS X v10.2.

  • Deprecated.

    Declaration

    Objective-C

    - (BOOL)isFontAvailable:(NSString *)faceName

    Import Statement

    Objective-C

    @import AppKit;

    Availability

    Available in OS X v10.0 and later.

    Deprecated in OS X v10.2.

  • Deprecated.

    Declaration

    Objective-C

    - (BOOL)isOutputStackInReverseOrder

    Import Statement

    Objective-C

    @import AppKit;

    Availability

    Available in OS X v10.0 and later.

    Deprecated in OS X v10.2.

  • note - note (OS X v10.2)

    Deprecated.

    Declaration

    Objective-C

    - (NSString *)note

    Import Statement

    Objective-C

    @import AppKit;

    Availability

    Available in OS X v10.0 and later.

    Deprecated in OS X v10.2.

Data Types

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

    Declaration

    Swift

    enum NSPrinterTableStatus : UInt { case OK case NotFound case Error }

    Objective-C

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

    Constants

    • OK

      NSPrinterTableOK

      Printer table was found and is valid.

      Available in OS X v10.0 and later.

    • NotFound

      NSPrinterTableNotFound

      Printer table was not found.

      Available in OS X v10.0 and later.

    • Error

      NSPrinterTableError

      Printer table is not valid.

      Available in OS X v10.0 and later.

    Discussion

    These constants are used by statusForTable:..

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.