NSPDFPanel Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/AppKit.framework
Availability
Available in OS X v10.9 and later.
Declared in
NSPDFPanel.h

Overview

An NSPDFPanel object is used to implement a Save or Export as PDF panel that’s consistent with the OS X user interface. A PDF panel has a variety of built-in customization controls, such as page orientation, paper size, and tags. It also supports the use of a custom accessory view controller that allows an app to specify how a PDF file should be created.

Tasks

Creating a PDF Panel

Managing the Contents of a PDF Panel

Displaying a PDF Panel

Properties

accessoryController

A view controller for the accessory view that the panel can present.

@property (retain) NSViewController *accessoryController
Discussion

The PDF panel passes an NSPDFInfo object to the accessory view controller to display the various attributes associated with the PDF file. Unlike a print panel (that is, an NSPrintPanel object), a PDF panel can have only one accessory view.

Availability
  • Available in OS X v10.9 and later.
Declared In
NSPDFPanel.h

defaultFileName

The initial value for the user-editable filename shown in the name field of the PDF panel.

@property (copy) NSString *defaultFileName
Discussion

The defaultFileName string should never include a file extension. By default, the string’s value is “Untitled” (or its equivalent for the current locale).

Availability
  • Available in OS X v10.9 and later.
Declared In
NSPDFPanel.h

options

A set of configuration options that determine the accessory views the PDF panel should display.

@property NSPDFPanelOptions options
Discussion

You specify a set of options by combining the appropriate constants defined in “NSPDFPanelOptions.”

Availability
  • Available in OS X v10.9 and later.
Declared In
NSPDFPanel.h

Class Methods

panel

Returns a new NSPDFPanel object.

+ (NSPDFPanel *)panel
Return Value

A new NSPDFPanel object or nil if an error occurred.

Availability
  • Available in OS X v10.9 and later.
Declared In
NSPDFPanel.h

Instance Methods

beginSheetWithPDFInfo:modalForWindow:completionHandler:

Presents a document-modal PDF panel.

- (void)beginSheetWithPDFInfo:(NSPDFInfo *)pdfInfo modalForWindow:(NSWindow *)docWindow completionHandler:(void (^)(NSInteger))completionHandler
Parameters
pdfInfo

The NSPDFInfo object describing the parameters to be used when creating the PDF file.

docWindow

The window in which the PDF panel will be presented.

completionHandler

The block called when the user dismisses the PDF panel.

Discussion

This method presents a slightly different PDF panel depending on whether the NSPDFPanelRequestsParentDirectory constant is set. If the user dismisses the panel without canceling it, this method updates the NSPDFInfo object with any changes the user makes.

Availability
  • Available in OS X v10.9 and later.
Declared In
NSPDFPanel.h

Constants

NSPDFPanelOptions

Constants used to configure the contents of a PDF panel.

enum {
   NSPDFPanelShowsPaperSize = 1 << 2,
   NSPDFPanelShowsOrientation = 1 << 3,
   NSPDFPanelRequestsParentDirectory = 1 << 24
};
typedef NSInteger NSPDFPanelOptions;
Constants
NSPDFPanelShowsPaperSize

The PDF panel shows a menu of paper sizes.

Available in OS X v10.9 and later.

Declared in NSPDFPanel.h.

NSPDFPanelShowsOrientation

The PDF panel shows the current orientation of the PDF contents, such as landscape or portrait.

Available in OS X v10.9 and later.

Declared in NSPDFPanel.h.

NSPDFPanelRequestsParentDirectory

The PDF panel doesn’t show a name field; instead, it allows the user to identify a directory in which to save multiple PDF files. If you set this flag, you’re responsible for appending a filename and the "pdf" extension to the resulting URL value in the NSPDFInfo object before proceeding with the creation of the PDF file (or calling the takeSettingsFromPDFInfo method of NSPrintInfo).

Available in OS X v10.9 and later.

Declared in NSPDFPanel.h.