Mac Developer Library

Developer

Quartz Framework Reference PDFView Class Reference

Options
Deployment Target:

On This Page
Language:

PDFView

Inheritance


Conforms To


Import Statement


Swift

import Quartz

Objective-C

@import Quartz;

Availability


Available in OS X v10.4 and later.

A PDFView object encapsulates the functionality of PDF Kit into a single widget that you can add to your application using Interface Builder.

PDFView may be the only class you need to deal with for adding PDF functionality to your application. It lets you display PDF data and allows users to select content, navigate through a document, set zoom level, and copy textual content to the Pasteboard. PDFView also keeps track of page history.

You can subclass PDFView to create a custom PDF viewer.

You can also create a custom PDF viewer by using the PDF Kit utility classes directly and not using PDFView at all.

  • Returns the document associated with a PDFView object.

    Declaration

    Swift

    func document() -> PDFDocument!

    Objective-C

    - (PDFDocument *)document

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.4 and later.

  • Associates a document with a PDFView object.

    Declaration

    Swift

    func setDocument(_ document: PDFDocument!)

    Objective-C

    - (void)setDocument:(PDFDocument *)document

    Discussion

    If a document was already associated with the view, it is released first and then document is associated with the view.

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.4 and later.

    See Also

    – document

  • Returns a Boolean value indicating whether the user can navigate to the previous page in the page history.

    Declaration

    Swift

    func canGoBack() -> Bool

    Objective-C

    - (BOOL)canGoBack

    Discussion

    The page history gets built as your application calls navigation methods such as goToDestination: and goToLastPage:.

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.4 and later.

    See Also

    – goBack:

  • Returns a Boolean value indicating whether the user can navigate to the next page in the page history.

    Declaration

    Swift

    func canGoForward() -> Bool

    Objective-C

    - (BOOL)canGoForward

    Discussion

    The page history gets built as your application calls navigation methods such as goToDestination: and goToLastPage:.

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.4 and later.

    See Also

    – goForward:

  • Returns a Boolean value indicating whether the user can navigate to the first page of the document.

    Declaration

    Swift

    func canGoToFirstPage() -> Bool

    Objective-C

    - (BOOL)canGoToFirstPage

    Discussion

    The return value will be YEStrue unless the view is already displaying the first page.

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.4 and later.

  • Returns a Boolean value indicating whether the user can navigate to the last page of the document.

    Declaration

    Swift

    func canGoToLastPage() -> Bool

    Objective-C

    - (BOOL)canGoToLastPage

    Discussion

    The return value will be YEStrue unless the view is already displaying the last page.

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.4 and later.

  • Returns a Boolean value indicating whether the user can navigate to the next page of the document.

    Declaration

    Swift

    func canGoToNextPage() -> Bool

    Objective-C

    - (BOOL)canGoToNextPage

    Discussion

    The return value will be YEStrue unless the view is displaying the last page.

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.4 and later.

  • Returns a Boolean value indicating whether the user can navigate to the previous page of the document.

    Declaration

    Swift

    func canGoToPreviousPage() -> Bool

    Objective-C

    - (BOOL)canGoToPreviousPage

    Discussion

    The return value will be YEStrue unless the view is displaying the first page.

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.4 and later.

  • Returns the current page.

    Declaration

    Swift

    func currentPage() -> PDFPage!

    Objective-C

    - (PDFPage *)currentPage

    Discussion

    When there are two pages in the view in a two-up mode, “current page” is the left page. For continuous modes, returns the page crossing a horizontal line halfway between the view’s top and bottom bounds.

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.4 and later.

  • Returns a PDFDestination object representing the current page and the current point in the view specified in page space.

    Declaration

    Swift

    func currentDestination() -> PDFDestination!

    Objective-C

    - (PDFDestination *)currentDestination

    Discussion

    Page space is a 72 dpi coordinate system with the origin at the lower-left corner of the current page.

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.4 and later.

    See Also

    – currentPage
    – goToDestination: (PDFDestination)

  • Navigates back one step in the page history.

    Declaration

    Swift

    @IBAction func goBack(_ sender: AnyObject!)

    Objective-C

    - (IBAction)goBack:(id)sender

    Discussion

    The page history gets built as your application calls navigation methods such as goToDestination: and goToLastPage:.

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.4 and later.

    See Also

    – canGoBack

  • Navigates forward one step in the page history.

    Declaration

    Swift

    @IBAction func goForward(_ sender: AnyObject!)

    Objective-C

    - (IBAction)goForward:(id)sender

    Discussion

    The page history gets built as your application calls navigation methods such as goToDestination: and goToLastPage:.

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.4 and later.

  • Navigates to the first page of the document.

    Declaration

    Swift

    @IBAction func goToFirstPage(_ sender: AnyObject!)

    Objective-C

    - (IBAction)goToFirstPage:(id)sender

    Discussion

    PDF Kit records the move in its page history.

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.4 and later.

  • Navigates to the last page of the document.

    Declaration

    Swift

    @IBAction func goToLastPage(_ sender: AnyObject!)

    Objective-C

    - (IBAction)goToLastPage:(id)sender

    Discussion

    PDF Kit records the move in its page history.

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.4 and later.

  • Navigates to the next page of the document.

    Declaration

    Swift

    @IBAction func goToNextPage(_ sender: AnyObject!)

    Objective-C

    - (IBAction)goToNextPage:(id)sender

    Discussion

    PDF Kit records the move in its page history.

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.4 and later.

  • Navigates to the previous page of the document.

    Declaration

    Swift

    @IBAction func goToPreviousPage(_ sender: AnyObject!)

    Objective-C

    - (IBAction)goToPreviousPage:(id)sender

    Discussion

    PDF Kit records the move in its page history.

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.4 and later.

  • Scrolls to the specified page.

    Declaration

    Swift

    func goToPage(_ page: PDFPage!)

    Objective-C

    - (void)goToPage:(PDFPage *)page

    Discussion

    PDF Kit records the move in its page history.

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.4 and later.

  • Navigates to the specified destination.

    Declaration

    Swift

    func goToDestination(_ destination: PDFDestination!)

    Objective-C

    - (void)goToDestination:(PDFDestination *)destination

    Discussion

    Destinations include a page and a point on the page specified in page space.

    Page space is a 72 dpi coordinate system with the origin at the lower-left corner of the current page.

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.4 and later.

    See Also

    – currentDestination (PDFDestination)
    – currentPage

  • Scrolls to the first character of the specified selection.

    Declaration

    Swift

    func goToSelection(_ selection: PDFSelection!)

    Objective-C

    - (void)goToSelection:(PDFSelection *)selection

    Discussion

    PDF Kit records the move in its page history.

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.4 and later.

  • Navigates to the specified rectangle on the specified page.

    Declaration

    Swift

    func goToRect(_ rect: NSRect, onPage page: PDFPage!)

    Objective-C

    - (void)goToRect:(NSRect)rect onPage:(PDFPage *)page

    Discussion

    If the specified rectangle is already visible, this method does nothing. This allows you to scroll the PDFView object to a specific PDFAnnotation or PDFSelection object, because both of these objects have bounds methods that return an annotation or selection position in page space.

    Note that rect is specified in page-space coordinates. Page space is a 72 dpi coordinate system with the origin at the lower-left corner of the current page.

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.5 and later.

  • Sets the display mode for the view.

    Declaration

    Swift

    func setDisplayMode(_ mode: PDFDisplayMode)

    Objective-C

    - (void)setDisplayMode:(PDFDisplayMode)mode

    Discussion

    Available display modes are single page, single-page continuous, two-up, and two-up continuous, as defined in Constants.

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.4 and later.

    See Also

    – displayMode

  • Returns the current display mode.

    Declaration

    Swift

    func displayMode() -> PDFDisplayMode

    Objective-C

    - (PDFDisplayMode)displayMode

    Discussion

    See Constants for possible values.

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.4 and later.

  • Toggles the display of page breaks.

    Declaration

    Swift

    func setDisplaysPageBreaks(_ breaks: Bool)

    Objective-C

    - (void)setDisplaysPageBreaks:(BOOL)breaks

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.4 and later.

  • Returns a Boolean value indicating whether the view is displaying page breaks.

    Declaration

    Swift

    func displaysPageBreaks() -> Bool

    Objective-C

    - (BOOL)displaysPageBreaks

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.4 and later.

  • Specifies the box to display and to clip to.

    Declaration

    Swift

    func setDisplayBox(_ box: PDFDisplayBox)

    Objective-C

    - (void)setDisplayBox:(PDFDisplayBox)box

    Discussion

    The values for box are defined in the PDFDisplayBox enumeration. The default value for this method is kPDFDisplayBoxCropBox.

    The available values for display boxes are defined in the Constants section in the PDFPage class.

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.4 and later.

    See Also

    – displayBox

  • Returns the current style of display box.

    Declaration

    Swift

    func displayBox() -> PDFDisplayBox

    Objective-C

    - (PDFDisplayBox)displayBox

    Discussion

    The available values for display boxes are defined in the Constants section in the PDFPage class.

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.4 and later.

  • Returns a Boolean value indicating whether the view will display the first page as a book cover (meaningful only when the document is in two-up or two-up continuous display mode).

    Declaration

    Swift

    func displaysAsBook() -> Bool

    Objective-C

    - (BOOL)displaysAsBook

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.4 and later.

  • Specifies whether the view should treat the document’s first page as a book cover.

    Declaration

    Swift

    func setDisplaysAsBook(_ asBook: Bool)

    Objective-C

    - (void)setDisplaysAsBook:(BOOL)asBook

    Discussion

    For two-up modes, a YEStrue value for this method specifies that the first page should be displayed by itself.

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.4 and later.

  • Specifies whether to use anti-aliasing in the view.

    Declaration

    Swift

    func setShouldAntiAlias(_ aliasing: Bool)

    Objective-C

    - (void)setShouldAntiAlias:(BOOL)aliasing

    Discussion

    The default value is YEStrue.

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.4 and later.

  • Returns a Boolean value indicating whether the view is anti-aliased.

    Declaration

    Swift

    func shouldAntiAlias() -> Bool

    Objective-C

    - (BOOL)shouldAntiAlias

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.4 and later.

  • Sets the greeking threshold to use for displaying text.

    Declaration

    Swift

    func setGreekingThreshold(_ threshold: CGFloat)

    Objective-C

    - (void)setGreekingThreshold:(CGFloat)threshold

    Discussion

    The default threshold is 3.0.

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.4 and later.

  • Returns the current greeking threshold for the view.

    Declaration

    Swift

    func greekingThreshold() -> CGFloat

    Objective-C

    - (CGFloat)greekingThreshold

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.4 and later.

  • Sets the view’s background color to the specified color.

    Declaration

    Swift

    @IBAction func takeBackgroundColorFrom(_ sender: AnyObject!)

    Objective-C

    - (IBAction)takeBackgroundColorFrom:(id)sender

    Discussion

    A view’s background is the area displayed to either side of a PDF document’s pages. The background also appears between pages when page breaks are enabled. The default color is a 50% gray.

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.4 and later.

  • Sets the view’s background color.

    Declaration

    Swift

    func setBackgroundColor(_ newColor: NSColor!)

    Objective-C

    - (void)setBackgroundColor:(NSColor *)newColor

    Discussion

    A view’s background is the area displayed to either side of a PDF document’s pages. The background also appears between pages when page breaks are enabled. The default color is a 50% gray.

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.4 and later.

  • Returns the view’s background color.

    Declaration

    Swift

    func backgroundColor() -> NSColor!

    Objective-C

    - (NSColor *)backgroundColor

    Discussion

    A view’s background is the area displayed to either side of a PDF document’s pages. The background also appears between pages when page breaks are enabled. The default color is a 50% gray.

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.4 and later.

  • Sets a delegate for the view.

    Declaration

    Swift

    func setDelegate(_ anObject: AnyObject!)

    Objective-C

    - (void)setDelegate:(id)anObject

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.4 and later.

    See Also

    – delegate

  • Returns the view’s delegate.

    Declaration

    Swift

    func delegate() -> AnyObject!

    Objective-C

    - (id)delegate

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.4 and later.

  • Sets the scale factor for the view.

    Declaration

    Swift

    func setScaleFactor(_ scale: CGFloat)

    Objective-C

    - (void)setScaleFactor:(CGFloat)scale

    Discussion

    The default value is 1.0, corresponding to actual size.

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.4 and later.

    See Also

    – scaleFactor

  • Returns the current scale factor for the view.

    Declaration

    Swift

    func scaleFactor() -> CGFloat

    Objective-C

    - (CGFloat)scaleFactor

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.4 and later.

  • Zooms in by increasing the scaling factor.

    Declaration

    Swift

    @IBAction func zoomIn(_ sender: AnyObject!)

    Objective-C

    - (IBAction)zoomIn:(id)sender

    Discussion

    Each invocation of zoomIn muliplies the scaling factor by the square root of 2.

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.4 and later.

  • Returns a Boolean value indicating whether the user can magnify the view—that is, zoom in.

    Declaration

    Swift

    func canZoomIn() -> Bool

    Objective-C

    - (BOOL)canZoomIn

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.4 and later.

  • Zooms out by decreasing the scaling factor.

    Declaration

    Swift

    @IBAction func zoomOut(_ sender: AnyObject!)

    Objective-C

    - (IBAction)zoomOut:(id)sender

    Discussion

    Each invocation of zoomOut divides the scaling factor by the square root of 2.

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.4 and later.

  • Returns a Boolean value indicating whether the user can view an expanded area—that is, zoom out.

    Declaration

    Swift

    func canZoomOut() -> Bool

    Objective-C

    - (BOOL)canZoomOut

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.4 and later.

  • Toggles whether the scaling factor applied to a view automatically responds to resizing.

    Declaration

    Swift

    func setAutoScales(_ newAuto: Bool)

    Objective-C

    - (void)setAutoScales:(BOOL)newAuto

    Discussion

    When set to autoscaling, the document scales to fill the PDFView object as the user resizes it.

    For the single-page and two-up continuous modes, autoscaling fits the page to the width of the view. For single-page and two-up noncontinuous modes, autoscaling provides best fit, in which the viewed pages are as large as possible while displaying in their entirety within the view.

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.4 and later.

    See Also

    – autoScales

  • Returns a Boolean value indicating whether autoscaling is set.

    Declaration

    Swift

    func autoScales() -> Bool

    Objective-C

    - (BOOL)autoScales

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.4 and later.

  • Returns the type of area the mouse cursor is over.

    Declaration

    Swift

    func areaOfInterestForMouse(_ event: NSEvent!) -> PDFAreaOfInterest

    Objective-C

    - (PDFAreaOfInterest)areaOfInterestForMouse:(NSEvent *)event

    Discussion

    The PDFAreaOfInterest enumeration defines the various area types. This method is for custom subclasses of the PDFView class. Use it if you override the NSResponder class’s mouseMoved: method or related methods.

    Refer to Constants for the various values of the area-of-interest constants. Each of these constants contributes to the value of the PDFAreaOfInterest bit field.

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.4 and later.

  • Sets the type of mouse cursor according to the type of area the mouse cursor is over.

    Declaration

    Swift

    func setCursorForAreaOfInterest(_ area: PDFAreaOfInterest)

    Objective-C

    - (void)setCursorForAreaOfInterest:(PDFAreaOfInterest)area

    Discussion

    This method is especially useful for custom subclasses of the PDFView class.

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.4 and later.

  • Performs the specified action.

    Declaration

    Swift

    func performAction(_ action: PDFAction!)

    Objective-C

    - (void)performAction:(PDFAction *)action

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.5 and later.

  • Returns the current selection.

    Declaration

    Swift

    func currentSelection() -> PDFSelection!

    Objective-C

    - (PDFSelection *)currentSelection

    Discussion

    Returns NULL if no selection exists.

    Note that this method returns the actual instance of the current PDFSelection object. Therefore, if you want to modify it, you should make a copy of the returned selection and modify that, instead.

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.4 and later.

  • Sets the selection.

    Declaration

    Swift

    func setCurrentSelection(_ selection: PDFSelection!)

    Objective-C

    - (void)setCurrentSelection:(PDFSelection *)selection

    Discussion

    The view redraws as necessary but does not scroll. If you need to scroll to the current selection, use scrollSelectionToVisible:. If you pass nil for the selection, this call is equivalent to calling clearSelection.

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.4 and later.

  • Selects all text in the document.

    Declaration

    Swift

    @IBAction func selectAll(_ sender: AnyObject!)

    Objective-C

    - (IBAction)selectAll:(id)sender

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.4 and later.

  • Clears the selection.

    Declaration

    Swift

    func clearSelection()

    Objective-C

    - (void)clearSelection

    Discussion

    The view redraws as necessary but does not scroll. This call is equivalent to calling [PDFView setCurrentSelection:NULL].

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.4 and later.

  • Copies the text in the selection, if any, to the Pasteboard.

    Declaration

    Swift

    func copy(_ sender: AnyObject!)

    Objective-C

    - (void)copy:(id)sender

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.4 and later.

  • Scrolls the view until the selection is visible.

    Declaration

    Swift

    func scrollSelectionToVisible(_ sender: AnyObject!)

    Objective-C

    - (void)scrollSelectionToVisible:(id)sender

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.4 and later.

  • Sets the selection, in an animated way, if desired.

    Declaration

    Swift

    func setCurrentSelection(_ selection: PDFSelection!, animate animate: Bool)

    Objective-C

    - (void)setCurrentSelection:(PDFSelection *)selection animate:(BOOL)animate

    Discussion

    This method behaves as setCurrentSelection:, but with the addition of animation, if animate is YEStrue. The animation serves to draw the user’s attention to the new selection, which can be useful when implementing search.

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.5 and later.

  • Highlights the specified array of selections.

    Declaration

    Swift

    func setHighlightedSelections(_ selections: [AnyObject]!)

    Objective-C

    - (void)setHighlightedSelections:(NSArray *)selections

    Discussion

    Unlike the selections users set (using, for example, setCurrentSelection:), the selections you specify in this method do not go away (that is, appear deselected) when users click elsewhere in the view or document. Instead, to deselect the selections, you must call [setHighlightedSelections:NULL] to remove them.

    You might use this method to highlight the set of matches from a text search. To prevent the user from confusing their own selections with selections you set using this method, it is recommended that you use a highlight color that is different from the user’s default text selection color.

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.5 and later.

  • Returns the array of selections that are highlighted using setHighlightedSelections.

    Declaration

    Swift

    func highlightedSelections() -> [AnyObject]!

    Objective-C

    - (NSArray *)highlightedSelections

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.5 and later.

  • A convenience method that calls – [[self document] setpassword:] with the password from the specified sender.

    Declaration

    Swift

    func takePasswordFrom(_ sender: AnyObject!)

    Objective-C

    - (void)takePasswordFrom:(id)sender

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.4 and later.

  • For use by subclasses of PDFView for custom rendering of pages.

    Declaration

    Swift

    func drawPage(_ page: PDFPage!)

    Objective-C

    - (void)drawPage:(PDFPage *)page

    Discussion

    Do not invoke this method, except by invoking it on super from a subclass.

    The PDFView class calls drawPage: as necessary for each visible page that requires rendering. In the PDFView class, this method erases page to white, calls [page drawInRect: pageRect withBox: [self displayBox]] , and then draws the selection, if any.

    You can override this method to draw on top of a PDF page or to control how pages are drawn. In these cases, invoke this method on super and then perform custom drawing on top of the PDF page.

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.4 and later.

  • For use by subclasses of PDFView for post-page rendering.

    Declaration

    Swift

    func drawPagePost(_ page: PDFPage!)

    Objective-C

    - (void)drawPagePost:(PDFPage *)page

    Discussion

    The default implementation of this method draws the text highlighting (if any) for the page. This method does not apply scaling or rotating to the current context to map to page space; instead, the context is in view-space coordinates (in which the origin is at the lower-left corner of the current PDF view).

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.5 and later.

  • Prints the document with the specified printer information.

    Declaration

    Swift

    func printWithInfo(_ printInfo: NSPrintInfo!, autoRotate doRotate: Bool)

    Objective-C

    - (void)printWithInfo:(NSPrintInfo *)printInfo autoRotate:(BOOL)doRotate

    Discussion

    If autoRotate is set to YEStrue, then ths method ignores the orientation attribute in the NSPrintInfo object and instead chooses the orientation that best fits the page to the paper size. This orientation occurs on a page-by-page basis.

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.4 and later.

  • Prints the document with the specified printer and page-scaling information.

    Declaration

    Swift

    func printWithInfo(_ printInfo: NSPrintInfo!, autoRotate doRotate: Bool, pageScaling scale: PDFPrintScalingMode)

    Objective-C

    - (void)printWithInfo:(NSPrintInfo *)printInfo autoRotate:(BOOL)doRotate pageScaling:(PDFPrintScalingMode)scale

    Discussion

    If pageScaling is set to kPDFPrintPageScaleToFit, each page is scaled up or down to best fit the paper size. If pageScaling is set to kPDFPrintPageScaleDownToFit, only large pages are scaled down to fit; small pages are not scaled up to fit. Specifying kPDFPrintPageScaleNone for pageScaling is equivalent to calling printWithInfo:autoRotate:. See PDFDocument for more information on page-scaling types.

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.5 and later.

  • Returns the innermost view used by PDFView or by your PDFView subclass.

    Declaration

    Swift

    func documentView() -> NSView!

    Objective-C

    - (NSView *)documentView

    Discussion

    The innermost view is the one displaying the visible document pages. This method is useful when converting coordinates from one view to another.

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.4 and later.

  • Returns the size needed to display a row of the current document page.

    Declaration

    Swift

    func rowSizeForPage(_ page: PDFPage!) -> NSSize

    Objective-C

    - (NSSize)rowSizeForPage:(PDFPage *)page

    Discussion

    The size is dependent on the current scale factor and display attributes.

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.4 and later.

  • Performs layout of the inner views.

    Declaration

    Swift

    func layoutDocumentView()

    Objective-C

    - (void)layoutDocumentView

    Discussion

    The PDFView actually contains several subviews, such as the document view (where the PDF is actually drawn) and a “matte view” (which may appear as a gray area around the PDF content, depending on the scaling). Changes to the PDF content may require changes to these inner views, so you must call this method explicitly if you use PDF Kit utility classes to add or remove a page, rotate a page, or perform other operations affecting visible layout.

    This method is called automatically from PDFView methods that affect the visible layout (such as setDocument:, setDisplayBox: or zoomIn:).

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.4 and later.

  • Determines whether the view can accept new PDF documents dragged into it by the user.

    Declaration

    Swift

    func allowsDragging() -> Bool

    Objective-C

    - (BOOL)allowsDragging

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.4 and later.

  • Specifies whether the view can accept drags.

    Declaration

    Swift

    func setAllowsDragging(_ allow: Bool)

    Objective-C

    - (void)setAllowsDragging:(BOOL)allow

    Discussion

    If set to YEStrue, the user can drag a new PDF document into the view. The new document is then displayed in the view, and the old document is released.

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.4 and later.

  • Returns an array of PDFPage objects that represent the currently visible pages.

    Declaration

    Swift

    func visiblePages() -> [AnyObject]!

    Objective-C

    - (NSArray *)visiblePages

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.5 and later.

  • Tells the PDF view that an annotation on the specified page has changed.

    Declaration

    Swift

    func annotationsChangedOnPage(_ page: PDFPage!)

    Objective-C

    - (void)annotationsChangedOnPage:(PDFPage *)page

    Discussion

    When the PDFView object receives this message, it rescans for tool tips and pop-ups and informs the PDFThumbailView objects so the thumbnail images can be redrawn.

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.5 and later.

  • Delegate method for overriding changes to scale factor.

    Declaration

    Swift

    func PDFViewWillChangeScaleFactor(_ sender: PDFView!, toScale scale: CGFloat) -> CGFloat

    Objective-C

    - (CGFloat)PDFViewWillChangeScaleFactor:(PDFView *)sender toScale:(CGFloat)scale

    Discussion

    By default, the scale factor is restricted to a range between 0.1 and 10.0 inclusive.

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.4 and later.

  • Delegate method for handling clicks on URL links in a view.

    Declaration

    Swift

    func PDFViewWillClickOnLink(_ sender: PDFView!, withURL url: NSURL!)

    Objective-C

    - (void)PDFViewWillClickOnLink:(PDFView *)sender withURL:(NSURL *)url

    Discussion

    By default, this method calls [[NSWorkspace sharedWorkspace] openURL:url].

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.5 and later.

  • Delegate method that performs a find operation.

    Declaration

    Swift

    func PDFViewPerformFind(_ sender: PDFView!)

    Objective-C

    - (void)PDFViewPerformFind:(PDFView *)sender

    Discussion

    Some PDFAction objects request a PDF viewer application to perform a find operation. A delegate responding to this method is called when users click an annotation with such an action.

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.5 and later.

  • Delegate method that performs a go-to operation.

    Declaration

    Swift

    func PDFViewPerformGoToPage(_ sender: PDFView!)

    Objective-C

    - (void)PDFViewPerformGoToPage:(PDFView *)sender

    Discussion

    Some PDFAction objects request a PDF viewer application to display a panel that allows users to enter a page number to go to. A delegate responding to this method is called when users click an annotation with such an action.

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.5 and later.

  • Delegate method that prints the current document.

    Declaration

    Swift

    func PDFViewPerformPrint(_ sender: PDFView!)

    Objective-C

    - (void)PDFViewPerformPrint:(PDFView *)sender

    Discussion

    Some PDFAction objects request a PDF viewer application to print the current document. A delegate responding to this method is called when users click an annotation with such an action.

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.5 and later.

  • Delegate method that opens a specified page.

    Declaration

    Swift

    func PDFViewOpenPDF(_ sender: PDFView!, forRemoteGoToAction action: PDFActionRemoteGoTo!)

    Objective-C

    - (void)PDFViewOpenPDF:(PDFView *)sender forRemoteGoToAction:(PDFActionRemoteGoTo *)action

    Discussion

    A delegate responding to this method is called to handle clicks in an annotation that contains a PDFActionRemoteGoTo action. Such an action contains a URL, a page index, and a point. The delegate should open the PDF document specified by the URL and go to the specified page and point. An easy way to do this is to create a PDFDocument object with the specified URL and then create a PDFDestination object with the specified page and point. Then, you can call goToDestination:.

    The default implementation of this method beeps.

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.5 and later.

  • Delegate method that overrides the job title used when the PDFView is printed.

    Declaration

    Swift

    func PDFViewPrintJobTitle(_ sender: PDFView!) -> String!

    Objective-C

    - (NSString *)PDFViewPrintJobTitle:(PDFView *)sender

    Discussion

    By default, this method uses the string, if any, associated with the “Title” key in the view’s PDFDocument attribute dictionary. If there is no such string, this method uses the last path component if the document is URL-based.

    Import Statement

    Objective-C

    @import Quartz;

    Swift

    import Quartz

    Availability

    Available in OS X v10.5 and later.