| Inherits from | |
| Conforms to | |
| Framework | Library/Frameworks/Quartz.framework/Frameworks/PDFKit.framework |
| Availability | Available in Mac OS X v10.4 and later. |
| Declared in | PDFView.h |
| Related sample code |
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.
– canGoBack
– canGoForward
– canGoToFirstPage
– canGoToLastPage
– canGoToNextPage
– canGoToPreviousPage
– currentPage
– currentDestination
– goBack:
– goForward:
– goToFirstPage:
– goToLastPage:
– goToNextPage:
– goToPreviousPage:
– goToPage:
– goToDestination:
– goToSelection:
– goToRect:onPage:
– setDisplayMode:
– displayMode
– setDisplaysPageBreaks:
– displaysPageBreaks
– setDisplayBox:
– displayBox
– displaysAsBook
– setDisplaysAsBook:
– setShouldAntiAlias:
– shouldAntiAlias
– setGreekingThreshold:
– greekingThreshold
– takeBackgroundColorFrom:
– setBackgroundColor:
– backgroundColor
– setScaleFactor:
– scaleFactor
– zoomIn:
– canZoomIn
– zoomOut:
– canZoomOut
– setAutoScales:
– autoScales
– currentSelection
– setCurrentSelection:
– selectAll:
– clearSelection
– copy:
– scrollSelectionToVisible:
– setCurrentSelection:animate:
– setHighlightedSelections:
– highlightedSelections
– pageForPoint:nearest:
– convertPoint:toPage:
– convertRect:toPage:
– convertPoint:fromPage:
– convertRect:fromPage:
– documentView
– rowSizeForPage:
– layoutDocumentView
– allowsDragging
– setAllowsDragging:
– visiblePages
– annotationsChangedOnPage:
– PDFViewWillChangeScaleFactor:toScale: delegate method
– PDFViewWillClickOnLink:withURL: delegate method
– PDFViewPerformFind: delegate method
– PDFViewPerformGoToPage: delegate method
– PDFViewPerformPrint: delegate method
– PDFViewOpenPDF:forRemoteGoToAction: delegate method
– PDFViewPrintJobTitle: delegate method
Determines whether the view can accept new PDF documents dragged into it by the user.
- (BOOL)allowsDragging
PDFView.hTells the PDF view that an annotation on the specified page has changed.
- (void)annotationsChangedOnPage:(PDFPage *)page
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.
PDFView.hReturns the type of area the mouse cursor is over.
- (PDFAreaOfInterest)areaOfInterestForMouse:(NSEvent *)theEvent
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.
PDFView.hReturns a Boolean value indicating whether autoscaling is set.
- (BOOL)autoScales
PDFView.hReturns the view’s background color.
- (NSColor *)backgroundColor
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.
PDFView.hReturns a Boolean value indicating whether the user can navigate to the previous page in the page history.
- (BOOL)canGoBack
The page history gets built as your application calls navigation methods such as goToDestination: and goToLastPage:.
PDFView.hReturns a Boolean value indicating whether the user can navigate to the next page in the page history.
- (BOOL)canGoForward
The page history gets built as your application calls navigation methods such as goToDestination: and goToLastPage:.
PDFView.hReturns a Boolean value indicating whether the user can navigate to the first page of the document.
- (BOOL)canGoToFirstPage
The return value will be YES unless the view is already displaying the first page.
PDFView.hReturns a Boolean value indicating whether the user can navigate to the last page of the document.
- (BOOL)canGoToLastPage
The return value will be YES unless the view is already displaying the last page.
PDFView.hReturns a Boolean value indicating whether the user can navigate to the next page of the document.
- (BOOL)canGoToNextPage
The return value will be YES unless the view is displaying the last page.
PDFView.hReturns a Boolean value indicating whether the user can navigate to the previous page of the document.
- (BOOL)canGoToPreviousPage
The return value will be YES unless the view is displaying the first page.
PDFView.hReturns a Boolean value indicating whether the user can magnify the view—that is, zoom in.
- (BOOL)canZoomIn
PDFView.hReturns a Boolean value indicating whether the user can view an expanded area—that is, zoom out.
- (BOOL)canZoomOut
PDFView.hClears the selection.
- (void)clearSelection
The view redraws as necessary but does not scroll. This call is equivalent to calling [PDFView setCurrentSelection:NULL].
PDFView.hConverts a point from page space to view space.
- (NSPoint)convertPoint:(NSPoint)point fromPage:(PDFPage *)page
Page space is a 72 dpi coordinate system with the origin at the lower-left corner of the current page. View space is a coordinate system with the origin at the lower-left corner of the current PDF view.
PDFView.hConverts a point from view space to page space.
- (NSPoint)convertPoint:(NSPoint)point toPage:(PDFPage *)page
Page space is a 72 dpi coordinate system with the origin at the lower-left corner of the current page. View space is a coordinate system with the origin at the lower-left corner of the current PDF view.
PDFView.hConverts a rectangle from page space to view space.
- (NSRect)convertRect:(NSRect)rect fromPage:(PDFPage *)page
Page space is a 72 dpi coordinate system with the origin at the lower-left corner of the current page. View space is a coordinate system with the origin at the lower-left corner of the current PDF view.
PDFView.hConverts a rectangle from view space to page space.
- (NSRect)convertRect:(NSRect)rect toPage:(PDFPage *)page
Page space is a 72 dpi coordinate system with the origin at the lower-left corner of the current page. View space is a coordinate system with the origin at the lower-left corner of the current PDF view.
PDFView.hCopies the text in the selection, if any, to the Pasteboard.
- (void)copy:(id)sender
PDFView.hReturns a PDFDestination object representing the current page and the current point in the view specified in page space.
- (PDFDestination *)currentDestination
Page space is a 72 dpi coordinate system with the origin at the lower-left corner of the current page.
– currentPage– goToDestination: (PDFDestination)PDFView.hReturns the current page.
- (PDFPage *)currentPage
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.
PDFView.hReturns the current selection.
- (PDFSelection *)currentSelection
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.
PDFView.hReturns the view’s delegate.
- (id)delegate
PDFView.hReturns the current style of display box.
- (PDFDisplayBox)displayBox
The available values for display boxes are defined in the Constants section in the PDFPage class.
PDFView.hReturns the current display mode.
- (PDFDisplayMode)displayMode
See “Constants” for possible values.
PDFView.hReturns 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).
- (BOOL)displaysAsBook
PDFView.hReturns a Boolean value indicating whether the view is displaying page breaks.
- (BOOL)displaysPageBreaks
PDFView.hReturns the document associated with a PDFView object.
- (PDFDocument *)document
PDFView.hReturns the innermost view used by PDFView or by your PDFView subclass.
- (NSView *)documentView
The innermost view is the one displaying the visible document pages. This method is useful when converting coordinates from one view to another.
PDFView.hFor use by subclasses of PDFView for custom rendering of pages.
- (void)drawPage:(PDFPage *)page
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.
PDFView.hFor use by subclasses of PDFView for post-page rendering.
- (void)drawPagePost:(PDFPage *)page
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).
PDFView.hNavigates back one step in the page history.
- (IBAction)goBack:(id)sender
The page history gets built as your application calls navigation methods such as goToDestination: and goToLastPage:.
PDFView.hNavigates forward one step in the page history.
- (IBAction)goForward:(id)sender
The page history gets built as your application calls navigation methods such as goToDestination: and goToLastPage:.
PDFView.hNavigates to the specified destination.
- (void)goToDestination:(PDFDestination *)destination
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.
– currentDestination (PDFDestination)– currentPagePDFView.hNavigates to the first page of the document.
- (IBAction)goToFirstPage:(id)sender
PDF Kit records the move in its page history.
PDFView.hNavigates to the last page of the document.
- (IBAction)goToLastPage:(id)sender
PDF Kit records the move in its page history.
PDFView.hNavigates to the next page of the document.
- (IBAction)goToNextPage:(id)sender
PDF Kit records the move in its page history.
PDFView.hScrolls to the specified page.
- (void)goToPage:(PDFPage *)page
PDF Kit records the move in its page history.
PDFView.hNavigates to the previous page of the document.
- (IBAction)goToPreviousPage:(id)sender
PDF Kit records the move in its page history.
PDFView.hNavigates to the specified rectangle on the specified page.
- (void)goToRect:(NSRect)rect onPage:(PDFPage *)page
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.
PDFView.hScrolls to the first character of the specified selection.
- (void)goToSelection:(PDFSelection *)selection
PDF Kit records the move in its page history.
PDFView.hReturns the current greeking threshold for the view.
- (float)greekingThreshold
PDFView.hReturns the array of selections that are highlighted using setHighlightedSelections.
- (NSArray *)highlightedSelections
PDFView.hPerforms layout of the inner views.
- (void)layoutDocumentView
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:).
PDFView.hReturns the page containing a point specified in view coordinates.
- (PDFPage *)pageForPoint:(NSPoint)point nearest:(BOOL)nearest
Returns NULL if there’s no page at the specified point and nearest is set to NO.
PDFView.hPerforms the specified action.
- (void)performAction:(PDFAction *)action
PDFView.hPrints the document with the specified printer information.
- (void)printWithInfo:(NSPrintInfo *)printInfo autoRotate:(BOOL)doRotate
If autoRotate is set to YES, 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.
PDFView.hPrints the document with the specified printer and page-scaling information.
- (void)printWithInfo:(NSPrintInfo *)printInfo autoRotate:(BOOL)doRotate pageScaling:(PDFPrintScalingMode)scale
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.
PDFView.hReturns the size needed to display a row of the current document page.
- (NSSize)rowSizeForPage:(PDFPage *)page
The size is dependent on the current scale factor and display attributes.
PDFView.hReturns the current scale factor for the view.
- (float)scaleFactor
PDFView.hScrolls the view until the selection is visible.
- (void)scrollSelectionToVisible:(id)sender
PDFView.hSelects all text in the document.
- (IBAction)selectAll:(id)sender
PDFView.hSpecifies whether the view can accept drags.
- (void)setAllowsDragging:(BOOL)allow
If set to YES, 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.
PDFView.hToggles whether the scaling factor applied to a view automatically responds to resizing.
- (void)setAutoScales:(BOOL)newAuto
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.
PDFView.hSets the view’s background color.
- (void)setBackgroundColor:(NSColor *)newColor
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.
PDFView.hSets the selection.
- (void)setCurrentSelection:(PDFSelection *)selection
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.
PDFView.hSets the selection, in an animated way, if desired.
- (void)setCurrentSelection:(PDFSelection *)selection animate:(BOOL)animate
This method behaves as setCurrentSelection:, but with the addition of animation, if animate is YES. The animation serves to draw the user’s attention to the new selection, which can be useful when implementing search.
PDFView.hSets the type of mouse cursor according to the type of area the mouse cursor is over.
- (void)setCursorForAreaOfInterest:(PDFAreaOfInterest)area
This method is especially useful for custom subclasses of the PDFView class.
PDFView.hSets a delegate for the view.
- (void)setDelegate:(id)anObject
PDFView.hSpecifies the box to display and to clip to.
- (void)setDisplayBox:(PDFDisplayBox)box
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.
PDFView.hSets the display mode for the view.
- (void)setDisplayMode:(PDFDisplayMode)mode
Available display modes are single page, single-page continuous, two-up, and two-up continuous, as defined in “Constants.”
PDFView.hSpecifies whether the view should treat the document’s first page as a book cover.
- (void)setDisplaysAsBook:(BOOL)asBook
For two-up modes, a YES value for this method specifies that the first page should be displayed by itself.
PDFView.hToggles the display of page breaks.
- (void)setDisplaysPageBreaks:(BOOL)breaks
PDFView.hAssociates a document with a PDFView object.
- (void)setDocument:(PDFDocument *)document
If a document was already associated with the view, it is released first and then document is associated with the view.
PDFView.hSets the greeking threshold to use for displaying text.
- (void)setGreekingThreshold:(float)threshold
The default threshold is 3.0.
PDFView.hHighlights the specified array of selections.
- (void)setHighlightedSelections:(NSArray *)selections
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.
PDFView.hSets the scale factor for the view.
- (void)setScaleFactor:(float)scale
The default value is 1.0, corresponding to actual size.
PDFView.hSpecifies whether to use anti-aliasing in the view.
- (void)setShouldAntiAlias:(BOOL)aliasing
The default value is YES.
PDFView.hReturns a Boolean value indicating whether the view is anti-aliased.
- (BOOL)shouldAntiAlias
PDFView.hSets the view’s background color to the specified color.
- (IBAction)takeBackgroundColorFrom:(id)sender
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.
PDFView.hA convenience method that calls – [[self document] setpassword:] with the password from the specified sender.
- (void)takePasswordFrom:(id)sender
PDFView.hReturns an array of PDFPage objects that represent the currently visible pages.
- (NSArray *)visiblePages
PDFView.hZooms in by increasing the scaling factor.
- (IBAction)zoomIn:(id)sender
Each invocation of zoomIn muliplies the scaling factor by the square root of 2.
PDFView.hZooms out by decreasing the scaling factor.
- (IBAction)zoomOut:(id)sender
Each invocation of zoomOut divides the scaling factor by the square root of 2.
PDFView.hDelegate method that opens a specified page.
- (void)PDFViewOpenPDF:(PDFView *)sender forRemoteGoToAction:(PDFActionRemoteGoTo *)action
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.
PDFView.hDelegate method that performs a find operation.
- (void)PDFViewPerformFind:(PDFView *)sender
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.
PDFView.hDelegate method that performs a go-to operation.
- (void)PDFViewPerformGoToPage:(PDFView *)sender
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.
PDFView.hDelegate method that prints the current document.
- (void)PDFViewPerformPrint:(PDFView *)sender
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.
PDFView.hDelegate method that overrides the job title used when the PDFView is printed.
- (NSString *)PDFViewPrintJobTitle:(PDFView *)sender
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.
PDFView.hDelegate method for overriding changes to scale factor.
- (float)PDFViewWillChangeScaleFactor:(PDFView *)sender toScale:(float)scale
By default, the scale factor is restricted to a range between 0.1 and 10.0 inclusive.
PDFView.hDelegate method for handling clicks on URL links in a view.
- (void)PDFViewWillClickOnLink:(PDFView *)sender withURL:(NSURL *)url
By default, this method calls [[NSWorkspace sharedWorkspace] openURL:url].
PDFView.hPDF views use the following display mode constants:
The following constants apply to mouse position over PDF view areas. These constants are components of a bit field and may be combined arbitrarily:
A PDFView object posts the following notifications:
Posted when the page history changes.
The notification object is the PDFView object itself.
PDFView.hPosted when a new document is associated with the view.
The notification object is the PDFView object itself.
PDFView.hPosted when a new page becomes the current page.
The notification object is the PDFView object itself.
PDFView.hPosted when the scale factor changes.
The notification object is the PDFView object itself.
PDFView.hPosted when the user clicks on an annotation.
The notification object is the PDFView object itself.
Use the @"PDFAnnotationHit" key to obtain userinfo of type PDFAnnotation *.
PDFView.hPosted when the user attempts to copy to the pasteboard without the appropriate permissions.
The notification object is the PDFView object itself.
PDFView.hPosted when the user attempts to print without the appropriate permissions.
The notification object is the PDFView object itself.
PDFView.hPosted before the user clicks an annotation.
The notification object is the PDFView object itself.
PDFView.hPosted when the current selection has changed.
The notification object is the PDFView object itself.
PDFView.hPosted when the display mode has changed.
The notification object is the PDFView object itself.
PDFView.hPosted when the display box has changed.
The notification object is the PDFView object itself.
PDFView.hLast updated: 2007-12-11