Mac Developer Library

Developer

AppKit Framework Reference NSPrintPanel Class Reference

Options
Deployment Target:

On This Page
Language:

NSPrintPanel

Inheritance


Conforms To


Import Statement


Swift

import AppKit

Objective-C

@import AppKit;

Availability


Available in OS X v10.0 and later.

An NSPrintPanel object creates the Print panel used to query the user for information about a print job. This panel may lets the user select the range of pages to print and the number of copies before executing the Print command.

Print panels can display a simplified interface when printing certain types of data. For example, the panel can display a list of print-setting presets, which lets the user enable print settings in groups as opposed to individually. Assigning an appropriate string to the jobStyleHint property activates the simplified interface and identifies which presets to display.

  • Returns a new NSPrintPanel object.

    Declaration

    Objective-C

    + (NSPrintPanel *)printPanel

    Return Value

    The print panel object.

    Import Statement

    Objective-C

    @import AppKit;

    Availability

    Available in OS X v10.0 and later.

  • The type of settings that the print panel displays.

    Declaration

    Swift

    var jobStyleHint: String?

    Objective-C

    @property(copy) NSString *jobStyleHint

    Discussion

    This property controls the set of items that appear in the Presets menu of the simplified Print panel interface. For a list of supported job style hints, see Job Style Hints. Set this property to nil to deactivate the simplified Print panel interface and use the standard interface instead (the equivalent of Core Printing’s kPMPresetGraphicsTypeGeneral).

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.2 and later.

  • options options Property

    The current configuration options for the Print panel.

    Declaration

    Swift

    var options: NSPrintPanelOptions

    Objective-C

    @property NSPrintPanelOptions options

    Discussion

    You can specify multiple options by adding them together. For a list of supported options, see NSPrintPanelOptions.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

  • Returns the title of the Print panel’s default button.

    Declaration

    Swift

    func defaultButtonTitle() -> String?

    Objective-C

    - (NSString *)defaultButtonTitle

    Return Value

    The title of the default button.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

  • Sets the title of the Print panel’s default button.

    Declaration

    Swift

    func setDefaultButtonTitle(_ defaultButtonTitle: String?)

    Objective-C

    - (void)setDefaultButtonTitle:(NSString *)defaultButtonTitle

    Parameters

    defaultButtonTitle

    The string to use for the button title.

    Discussion

    You can use this method to change the default button title from "Print” to something more appropriate for your usage of the panel. For example, if you are using the Print panel to save a representation of the document to a file, you might change the title to “Save”.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

  • The HTML help anchor associated with the Print panel.

    Declaration

    Swift

    var helpAnchor: String?

    Objective-C

    @property(copy) NSString *helpAnchor

    Discussion

    Use this property to specify the anchor name in your Apple Help file. The string you assign should contain only the name portion of the HTML anchor element.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

  • Adds a custom controller to the Print panel to manage an accessory view.

    Declaration

    Swift

    func addAccessoryController(_ accessoryController: NSViewController)

    Objective-C

    - (void)addAccessoryController:(NSViewController<NSPrintPanelAccessorizing> *)accessoryController

    Parameters

    accessoryController

    The view controller that manages your custom accessory views.

    Discussion

    You can invoke this method multiple times to add multiple accessory views to the receiver’s Print panel.

    The title for the accessory view is obtained from the title method of the view controller object.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

  • Removes the specified controller and accessory view from the Print panel.

    Declaration

    Swift

    func removeAccessoryController(_ accessoryController: NSViewController)

    Objective-C

    - (void)removeAccessoryController:(NSViewController<NSPrintPanelAccessorizing> *)accessoryController

    Parameters

    accessoryController

    The view controller to remove.

    Discussion

    You use this method to remove any view controllers responsible for displaying accessory views you do not want to include in the Print panel.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

  • The array of controller objects that manage the Print panel’s accessory views. (read-only)

    Declaration

    Swift

    var accessoryControllers: [AnyObject] { get }

    Objective-C

    @property(readonly, copy) NSArray *accessoryControllers

    Discussion

    This property contains an array of NSViewController objects, each of which represents an accessory view added using the addAccessoryController: method.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

  • Displays a Print panel sheet and runs it modally for the specified window.

    Declaration

    Swift

    func beginSheetWithPrintInfo(_ printInfo: NSPrintInfo, modalForWindow docWindow: NSWindow, delegate modalDelegate: AnyObject?, didEndSelector didEndSelector: Selector, contextInfo contextInfo: UnsafeMutablePointer<Void>)

    Objective-C

    - (void)beginSheetWithPrintInfo:(NSPrintInfo *)printInfo modalForWindow:(NSWindow *)docWindow delegate:(id)modalDelegate didEndSelector:(SEL)didEndSelector contextInfo:(void *)contextInfo

    Parameters

    printInfo

    The printing information for the current job.

    docWindow

    The window on which to display the sheet.

    modalDelegate

    A modal delegate object assigned to handle the closing of the Print panel sheet.

    didEndSelector

    The selector to call on the modal delegate object when the sheet is dismissed. The signature of this method is listed in the Discussion section.

    contextInfo

    A pointer to context data the didEndSelector method needs to process the sheet. This data is user-defined and may be NULL.

    Discussion

    When the modal session ends, if modalDelegate and didEndSelector contain non-nil values, the method specified by didEndSelector is invoked on the object in modalDelegate. The data you specify in contextInfo is passed as a parameter to the didEndSelector method. The object in modalDelegate is not the same as a delegate assigned to the panel. Modal delegates for sheets are temporary and the relationship lasts only until the sheet is dismissed.

    The didEndSelector argument must have the following signature:

    • - (void)printPanelDidEnd:(NSPrintPanel *)printPanel returnCode:(NSInteger)returnCode contextInfo: (void *)contextInfo;

    The value passed as returnCode is either NSCancelButton or NSOKButton. The value NSOKButton is returned even if the user clicked the Preview button.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Displays the receiver's Print panel and begins the modal loop.

    Declaration

    Swift

    func runModal() -> Int

    Objective-C

    - (NSInteger)runModal

    Return Value

    NSCancelButton if the user clicks the Cancel button; otherwise NSOKButton.

    Discussion

    This method uses the printing information associated with the current printing operation.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    – printInfo (NSPrintOperation)

  • Displays the receiver’s Print panel and runs the modal loop using the specified printing information.

    Declaration

    Swift

    func runModalWithPrintInfo(_ printInfo: NSPrintInfo) -> Int

    Objective-C

    - (NSInteger)runModalWithPrintInfo:(NSPrintInfo *)printInfo

    Parameters

    printInfo

    The printing information to use while displaying the Print panel.

    Return Value

    NSCancelButton if the user clicks the Cancel button; otherwise NSOKButton.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

  • printInfo printInfo Property

    The printing information associated with the running Print panel. (read-only)

    Declaration

    Swift

    var printInfo: NSPrintInfo { get }

    Objective-C

    @property(readonly, strong) NSPrintInfo *printInfo

    Discussion

    The value in this property is nil if the Print panel is not currently running.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.

  • Updates the receiver with information from the current NSPrintOperation object.

    Declaration

    Objective-C

    - (void)updateFromPrintInfo

    Discussion

    Do not invoke this method directly—it is invoked automatically before the Print panel is displayed.

    Import Statement

    Objective-C

    @import AppKit;

    Availability

    Available in OS X v10.0 and later.

    Deprecated in OS X v10.5.

    See Also

    – finalWritePrintInfo
    + currentOperation (NSPrintOperation)

  • Writes the receiver's printing attributes to the current NSPrintOperation object.

    Declaration

    Objective-C

    - (void)finalWritePrintInfo

    Discussion

    Do not invoke this method directly—it is invoked automatically when the Print panel is dismissed by the user clicking the OK button.

    Import Statement

    Objective-C

    @import AppKit;

    Availability

    Available in OS X v10.0 and later.

    Deprecated in OS X v10.5.

    See Also

    – updateFromPrintInfo
    + currentOperation (NSPrintOperation)

  • Returns the accessory view of the receiver.

    Deprecation Statement

    Use accessoryControllers instead.

    Declaration

    Objective-C

    - (NSView *)accessoryView

    Return Value

    The accessory view of the receiver, if any.

    Import Statement

    Objective-C

    @import AppKit;

    Availability

    Available in OS X v10.0 and later.

    Deprecated in OS X v10.5.

  • Sets the accessory view for the receiver.

    Deprecation Statement

    Use addAccessoryController: instead.

    Declaration

    Objective-C

    - (void)setAccessoryView:(NSView *)aView

    Parameters

    aView

    The view containing the controls and information you want to add to the print panel. Specify nil to remove the receiver's current accessory view.

    Discussion

    You can use an accessory view to add printing controls and information to the standard print panel. You set your accessory view prior to displaying the print panel. Upon display, the print panel adds your application's name as an item to its pane-selection pull-down menu. When the user selects this item, the print panel displays your accessory view.

    Import Statement

    Objective-C

    @import AppKit;

    Availability

    Available in OS X v10.0 and later.

    Deprecated in OS X v10.5.

  • pickedButton: - pickedButton: Available in OS X v10.0 through OS X v10.4

    Deprecated.

    Deprecation Statement

    No alternative. Do not use.

    Declaration

    Objective-C

    - (void)pickedButton:(id)sender

    Import Statement

    Objective-C

    @import AppKit;

    Availability

    Available in OS X v10.0 through OS X v10.4.

    Not available to 64-bit applications.

  • pickedAllPages: - pickedAllPages: Available in OS X v10.0 through OS X v10.4

    Deprecated.

    Deprecation Statement

    No alternative. Do not use.

    Declaration

    Objective-C

    - (void)pickedAllPages:(id)sender

    Import Statement

    Objective-C

    @import AppKit;

    Availability

    Available in OS X v10.0 through OS X v10.4.

    Not available to 64-bit applications.

  • pickedLayoutList: - pickedLayoutList: Available in OS X v10.0 through OS X v10.4

    Deprecated.

    Deprecation Statement

    No alternative. Do not use.

    Declaration

    Objective-C

    - (void)pickedLayoutList:(id)sender

    Import Statement

    Objective-C

    @import AppKit;

    Availability

    Available in OS X v10.0 through OS X v10.4.

    Not available to 64-bit applications.

  • Constants to be used as job style hints for activating the simplified Print panel interface and setting the options to display.

    Declaration

    Swift

    let NSPrintPhotoJobStyleHint: String let NSPrintAllPresetsJobStyleHint: String let NSPrintNoPresetsJobStyleHint: String

    Objective-C

    NSString *const NSPrintPhotoJobStyleHint; NSString *const NSPrintAllPresetsJobStyleHint; NSString *const NSPrintNoPresetsJobStyleHint;

    Constants

    • NSPrintPhotoJobStyleHint

      NSPrintPhotoJobStyleHint

      Output contains photographic data.

      Available in OS X v10.2 and later.

    • NSPrintAllPresetsJobStyleHint

      NSPrintAllPresetsJobStyleHint

      Output appropriate to all graphics types. Equivalent to Core Printing’s kPMPresetGraphicsTypeAll.

      Available in OS X v10.6 and later.

    • NSPrintNoPresetsJobStyleHint

      NSPrintNoPresetsJobStyleHint

      Output excludes all graphics printing. Equivalent to Core Printing’s kPMPresetGraphicsTypeNone.

      Available in OS X v10.6 and later.

  • These constants are used to configure the contents of the main Print panel.

    Declaration

    Swift

    struct NSPrintPanelOptions : RawOptionSetType { init(_ rawValue: UInt) init(rawValue rawValue: UInt) static var ShowsCopies: NSPrintPanelOptions { get } static var ShowsPageRange: NSPrintPanelOptions { get } static var ShowsPaperSize: NSPrintPanelOptions { get } static var ShowsOrientation: NSPrintPanelOptions { get } static var ShowsScaling: NSPrintPanelOptions { get } static var ShowsPrintSelection: NSPrintPanelOptions { get } static var ShowsPageSetupAccessory: NSPrintPanelOptions { get } static var ShowsPreview: NSPrintPanelOptions { get } }

    Objective-C

    typedef enum NSPrintPanelOptions : NSUIntger { NSPrintPanelShowsCopies = 1 << 0, NSPrintPanelShowsPageRange = 1 << 1, NSPrintPanelShowsPaperSize = 1 << 2, NSPrintPanelShowsOrientation = 1 << 3, NSPrintPanelShowsScaling = 1 << 4, NSPrintPanelShowsPrintSelection = 1 << 5, NSPrintPanelShowsPageSetupAccessory = 1 << 8, NSPrintPanelShowsPreview = 1 << 17 } NSPrintPanelOptions;

    Constants

    • ShowsCopies

      NSPrintPanelShowsCopies

      The Print panel includes a field for manipulating the number of copies being printed. This field is separate from any accessory views.

      Available in OS X v10.5 and later.

    • ShowsPageRange

      NSPrintPanelShowsPageRange

      The Print panel includes a set of fields for manipulating the range of pages being printed. These fields are separate from any accessory views.

      Available in OS X v10.5 and later.

    • ShowsPaperSize

      NSPrintPanelShowsPaperSize

      The Print panel includes a control for manipulating the paper size of the printer. This control is separate from any accessory views.

      Available in OS X v10.5 and later.

    • ShowsOrientation

      NSPrintPanelShowsOrientation

      The Print panel includes a control for manipulating the page orientation. This control is separate from any accessory views.

      Available in OS X v10.5 and later.

    • ShowsScaling

      NSPrintPanelShowsScaling

      The Print panel includes a control for scaling the printed output. This control is separate from any accessory views.

      Available in OS X v10.5 and later.

    • ShowsPrintSelection

      NSPrintPanelShowsPrintSelection

      The Print panel includes an additional selection option for paper range. This control is separate from any accessory views.

      Available in OS X v10.6 and later.

    • ShowsPageSetupAccessory

      NSPrintPanelShowsPageSetupAccessory

      The Print panel includes a separate accessory view for manipulating the paper size, orientation, and scaling attributes. Page setup fields that are already configured for display on the main portion of the Print panel appear there and not on this accessory panel.

      Available in OS X v10.5 and later.

    • ShowsPreview

      NSPrintPanelShowsPreview

      The Print panel displays a built-in preview of the document contents. This option is only appropriate when the Print panel is used in conjunction with an NSPrintOperation object to print a document.

      Available in OS X v10.5 and later.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.5 and later.