PSPDFPageView


@interface PSPDFPageView
    : UIView <PSPDFRenderTaskDelegate, PSPDFResizableViewDelegate>

Display a single PDF page. View is reused. You can add your own views on top of the annotationContainerView (e.g. custom annotations) Events from a attached UIScrollView will be relayed to all visible PSPDFPageView classes.

  • Unavailable

    Undocumented

    Declaration

    Objective-C

    PSPDF_EMPTY_INIT_UNAVAILABLE
  • Unavailable

    Undocumented

    Declaration

    Objective-C

    PSPDF_EMPTY_INIT_UNAVAILABLE
  • Redraw the renderView (dynamically rendered PDF for maximum sharpness, updated on every zoom level.)

    Declaration

    Objective-C

    - (void)updateRenderView;

    Swift

    func updateRenderView()
  • Redraw renderView and contentView.

    Declaration

    Objective-C

    - (void)updateView;

    Swift

    func update()
  • If annotations are already loaded, and the annotation is a view, access it here. (Most PDF annotations are actually rendered into the page; except annotations that return YES for isOverlay, like links or notes.

    Declaration

    Objective-C

    - (nullable UIView<PSPDFAnnotationPresenting> *)annotationViewForAnnotation:
        (nonnull PSPDFAnnotation *)annotation;

    Swift

    func annotationView(for annotation: PSPDFAnnotation) -> (UIView & PSPDFAnnotationPresenting)?
  • UIImageView displaying the whole document.

    Declaration

    Objective-C

    @property (readonly, nonatomic) UIImageView *_Nonnull contentView;

    Swift

    var contentView: UIImageView { get }
  • UIImageView for the zoomed in state.

    Declaration

    Objective-C

    @property (readonly, nonatomic) UIImageView *_Nonnull renderView;

    Swift

    var renderView: UIImageView { get }
  • Container view for all overlay annotations.

    This is just a named subclass of UIView that will always track the frame of the PSPDFPageView. It’s useful to coordinate this with your own subviews to get the zIndex right.

    Warning

    Most annotations will not be rendered as overlays or only when they are currently being selected. Rendering annotations within the pageView has several advantages including performance or view color multiplication (in case of highlight annotations) Do not manually add/remove views into the container view. Contents is managed. Views should respond to the PSPDFAnnotationPresenting, especially the annotation method.

    Declaration

    Objective-C

    @property (readonly, nonatomic)
        PSPDFAnnotationContainerView *_Nonnull annotationContainerView;

    Swift

    var annotationContainerView: PSPDFAnnotationContainerView { get }
  • Access the selectionView. (handles text selection)

    Declaration

    Objective-C

    @property (readonly, nonatomic) PSPDFTextSelectionView *_Nonnull selectionView;

    Swift

    var selectionView: PSPDFTextSelectionView { get }
  • Access the render status view that is displayed on top of a page while we are rendering.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic)
        PSPDFRenderStatusView *_Nonnull renderStatusView;

    Swift

    var renderStatusView: PSPDFRenderStatusView { get set }
  • Top right offset. Defaults to 30.f.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) CGFloat renderStatusViewOffset;

    Swift

    var renderStatusViewOffset: CGFloat { get set }
  • The PDF scale the current page is rendered with.

    Declaration

    Objective-C

    @property (readonly, nonatomic) CGFloat PDFScale;

    Swift

    var pdfScale: CGFloat { get }
  • Current CGRect of the part of the page that’s visible. Screen coordinate space.

    Note

    If the scroll view is currently decelerating, this will show the TARGET rect, not the one that’s currently animating.

    Declaration

    Objective-C

    @property (readonly, nonatomic) CGRect visibleRect;

    Swift

    var visibleRect: CGRect { get }
  • Color used to indicate link or form objects.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) UIColor *_Nonnull highlightColor;

    Swift

    var highlightColor: UIColor { get set }
  • Convert a view point to the corresponding PDF point.

    Declaration

    Objective-C

    - (CGPoint)convertViewPointToPDFPoint:(CGPoint)viewPoint;

    Swift

    func convertPoint(toPDFPoint viewPoint: CGPoint) -> CGPoint
  • Convert a PDF point to the corresponding view point.

    Declaration

    Objective-C

    - (CGPoint)convertPDFPointToViewPoint:(CGPoint)pdfPoint;

    Swift

    func convertPDFPoint(toViewPoint pdfPoint: CGPoint) -> CGPoint
  • Convert a view rect to the corresponding pdf rect.

    Note

    Important: The viewRect must be well–formed! Do not, for example, pass something with a less–than–zero width…

    Declaration

    Objective-C

    - (CGRect)convertViewRectToPDFRect:(CGRect)viewRect;

    Swift

    func convertRect(toPDFRect viewRect: CGRect) -> CGRect
  • Convert a PDF rect to the corresponding view rect

    Note

    Important: The viewRect must be well–formed! Do not, for example, pass something with a less–than–zero width…

    Declaration

    Objective-C

    - (CGRect)convertPDFRectToViewRect:(CGRect)pdfRect;

    Swift

    func convertPDFRect(toViewRect pdfRect: CGRect) -> CGRect
  • Get the glyphs/words on a specific page.

    Declaration

    Objective-C

    - (nonnull NSDictionary<NSString *, id> *)
    objectsAtPoint:(CGPoint)viewPoint
           options:(nullable NSDictionary<NSString *, NSNumber *> *)options;

    Swift

    func objects(at viewPoint: CGPoint, options: [String : NSNumber]? = nil) -> [String : Any]
  • Get the glyphs/words on a specific rect. Usage e.g. NSDictionary *objects = [pageView objectsAtRect:rect options:@{PSPDFObjectsWordsKey: @ YES}];

    Declaration

    Objective-C

    - (nonnull NSDictionary<NSString *, id> *)
    objectsAtRect:(CGRect)viewRect
          options:(nullable NSDictionary<NSString *, NSNumber *> *)options;

    Swift

    func objects(at viewRect: CGRect, options: [String : NSNumber]? = nil) -> [String : Any]
  • Access the UIScrollView that is responsible for zooming this page view if available.

    Declaration

    Objective-C

    @property (readonly, nonatomic, nullable) UIScrollView *zoomView;

    Swift

    var zoomView: UIScrollView? { get }
  • Returns an array of UIView PSPDFAnnotationPresenting objects currently in the view hierarchy.

    Declaration

    Objective-C

    @property (readonly, nonatomic) NSArray<UIView<PSPDFAnnotationPresenting> *>
        *_Nonnull visibleAnnotationViews;

    Swift

    var visibleAnnotationViews: [UIView & PSPDFAnnotationPresenting] { get }
  • Page that is displayed. Readonly.

    Declaration

    Objective-C

    @property (readonly, nonatomic) PSPDFPageIndex pageIndex;

    Swift

    var pageIndex: PageIndex { get }
  • Shortcut to access the current page info of the set page.

    Declaration

    Objective-C

    @property (readonly, nonatomic, nullable) PSPDFPageInfo *pageInfo;

    Swift

    var pageInfo: PSPDFPageInfo? { get }
  • Show signature menu.

    Declaration

    Objective-C

    - (void)showNewSignatureMenuAtRect:(CGRect)viewRect
                  signatureFormElement:
                      (nullable PSPDFSignatureFormElement *)signatureFormElement
                               options:(nullable NSDictionary *)options
                              animated:(BOOL)animated;

    Swift

    func showNewSignatureMenu(at viewRect: CGRect, signatureFormElement: PSPDFSignatureFormElement?, options: [AnyHashable : Any]? = nil, animated: Bool)
  • Show digital signature menu. Only shown when signatureField is signed already.

    Declaration

    Objective-C

    - (BOOL)showDigitalSignatureMenuForSignatureField:
                (nonnull PSPDFSignatureFormElement *)signatureField
                                             animated:(BOOL)animated;

    Swift

    func showDigitalSignatureMenu(forSignatureField signatureField: PSPDFSignatureFormElement, animated: Bool) -> Bool
  • Returns the default color options for the specified annotation type.

    Note

    The default implementation uses colors from the style manager color presets for certain annotation types (e.g., PSPDFAnnotationTypeHighlight).

    Declaration

    Objective-C

    - (nonnull NSArray<UIColor *> *)defaultColorOptionsForAnnotationType:
        (PSPDFAnnotationType)annotationType;

    Swift

    func defaultColorOptions(for annotationType: AnnotationType) -> [UIColor]
  • Controls if the annotation inspector is used or manipulation via UIMenuController.

    Declaration

    Objective-C

    - (BOOL)useAnnotationInspectorForAnnotations:
        (nonnull NSArray<PSPDFAnnotation *> *)annotations;

    Swift

    func useAnnotationInspector(for annotations: [PSPDFAnnotation]) -> Bool
  • Used to prepare the UIMenuController-based color menu.

    Declaration

    Objective-C

    - (void)selectColorForAnnotation:(nonnull PSPDFAnnotation *)annotation
                         isFillColor:(BOOL)isFillColor;

    Swift

    func selectColor(for annotation: PSPDFAnnotation, isFillColor: Bool)
  • By default, the highlight menu on iPad and iPhone is different, since on iPad there’s more screen real estate - thus we pack the menu options into a Style… submenu on iPhone. Override this to customize the behavior. Returns !PSPDFIsiPad(); by default.

    Declaration

    Objective-C

    @property (readonly, nonatomic) BOOL shouldMoveStyleMenuEntriesIntoSubmenu;

    Swift

    var shouldMoveStyleMenuEntriesIntoSubmenu: Bool { get }
  • Will create and show the action sheet on long-press above a PSPDFLinkAnnotation. Return YES if this was successful.

    Declaration

    Objective-C

    - (BOOL)showLinkPreviewActionSheetForAnnotation:
                (nonnull PSPDFLinkAnnotation *)annotation
                                           fromRect:(CGRect)viewRect
                                           animated:(BOOL)animated;

    Swift

    func showLinkPreviewActionSheet(for annotation: PSPDFLinkAnnotation, from viewRect: CGRect, animated: Bool) -> Bool
  • Show menu if annotation/text is selected.

    Declaration

    Objective-C

    - (void)showMenuIfSelectedAnimated:(BOOL)animated;

    Swift

    func showMenuIfSelected(animated: Bool)
  • Undocumented

    Declaration

    Objective-C

    - (void)showMenuIfSelectedAnimated:(BOOL)animated allowPopovers:(BOOL)allowPopovers;

    Swift

    func showMenuIfSelected(animated: Bool, allowPopovers: Bool)
  • Undocumented

    Declaration

    Objective-C

    - (BOOL)canCreateAnnotationsShowMessage:(BOOL)showMessage;

    Swift

    func canCreateAnnotationsShowMessage(_ showMessage: Bool) -> Bool
  • Undocumented

    Declaration

    Objective-C

    - (void)setAnnotation:(PSPDFAnnotation *)annotation forAnnotationView:(UIView<PSPDFAnnotationPresenting> *)annotationView;

    Swift

    func setAnnotation(_ annotation: PSPDFAnnotation, forAnnotationView annotationView: UIView & PSPDFAnnotationPresenting)
  • Undocumented

    Declaration

    Objective-C

    - (nullable PSPDFAnnotation *)annotationForAnnotationView:(UIView<PSPDFAnnotationPresenting> *)annotationView;

    Swift

    func annotation(forAnnotationView annotationView: UIView & PSPDFAnnotationPresenting) -> PSPDFAnnotation?
  • Currently selected annotations (selected by a tap; showing a menu)

    Declaration

    Objective-C

    @property (readwrite, copy, nonatomic, null_resettable)
        NSArray<PSPDFAnnotation *> *selectedAnnotations;

    Swift

    var selectedAnnotations: [PSPDFAnnotation]! { get set }
  • Hit-testing for a single PSPDFPageView. This is usually a relayed event from the parent PSPDFScrollView. Returns YES if the tap has been handled, else NO.

    All annotations for the current page are loaded and hit-tested (except PSPDFAnnotationTypeLink; which has already been handled by now)

    If an annotation has been hit (via [annotation hitTest:tapPoint]; convert the tapPoint in PDF coordinate space via convertViewPointToPDFPoint) then we call showMenuForAnnotation.

    If the tap didn’t hit an annotation but we are showing a UIMenuController menu; we hide that and set the touch as processed.

    Declaration

    Objective-C

    - (BOOL)singleTapped:(nonnull UITapGestureRecognizer *)recognizer;

    Swift

    func singleTapped(_ recognizer: UITapGestureRecognizer) -> Bool
  • Handle long press, potentially relay to subviews.

    Declaration

    Objective-C

    - (BOOL)longPress:(nonnull UILongPressGestureRecognizer *)recognizer;

    Swift

    func longPress(_ recognizer: UILongPressGestureRecognizer) -> Bool
  • Add an annotation to the current pageView. This will either queue a re-render of the PDF, or add an UIView subclass for the matching annotation, depending on the annotation type and the value of isOverlay.

    Note

    In PSPDFKit, annotations are managed in two ways:

    1) Annotations that are fixed and rendered with the page image. Those annotations are PSPDFHighlightAnnotation, PSPDFSquareAnnotation, PSPDFInkAnnotation and more. Pretty much all more or less static annotations are handled this way.

    2) Then, there are the more dynamic annotations like PSPDFLinkAnnotation and PSPDFNoteAnnotation. Those annotations are not part of the rendered image but are actual subviews in PSPDFPageView. Those annotations return YES on the isOverlay property.

    This method is called recursively with all annotation types except if they return isOverlay = NO. In case of isOverlay = NO, it will call updateView to re-render the page.

    Warning

    This will not change anything on the data model below. Also add an annotation to the document object.

    Declaration

    Objective-C

    - (void)addAnnotation:(nonnull PSPDFAnnotation *)annotation
                  options:(nullable NSDictionary<NSString *, NSNumber *> *)options
                 animated:(BOOL)animated;

    Swift

    func add(_ annotation: PSPDFAnnotation, options: [String : NSNumber]? = nil, animated: Bool)
  • Removes an annotation from the view, either by re-rendering the page image or removing a matching UIView-subclass of the annotation was added as an overlay.

    Note

    This will not change the data model of the document.

    Declaration

    Objective-C

    - (BOOL)removeAnnotation:(nonnull PSPDFAnnotation *)annotation
                     options:
                         (nullable NSDictionary<NSString *, NSNumber *> *)options
                    animated:(BOOL)animated;

    Swift

    func remove(_ annotation: PSPDFAnnotation, options: [String : NSNumber]? = nil, animated: Bool) -> Bool
  • Select annotation and show the menu for it.

    Declaration

    Objective-C

    - (void)selectAnnotation:(nonnull PSPDFAnnotation *)annotation
                    animated:(BOOL)animated;

    Swift

    func select(_ annotation: PSPDFAnnotation, animated: Bool)
  • Subclass to change shadow behavior.

    Declaration

    Objective-C

    - (void)updateShadowAnimated:(BOOL)animated;

    Swift

    func updateShadow(animated: Bool)
  • Returns annotations that we could tap on. (checks against editableAnnotationTypes) The point will have a variance of a few pixels to improve touch recognition.

    Declaration

    Objective-C

    - (nonnull NSArray<PSPDFAnnotation *> *)tappableAnnotationsAtPoint:
        (CGPoint)viewPoint;

    Swift

    func tappableAnnotations(at viewPoint: CGPoint) -> [PSPDFAnnotation]
  • Same as above, but will be called when we’re detecting a long press.

    Declaration

    Objective-C

    - (nonnull NSArray<PSPDFAnnotation *> *)tappableAnnotationsForLongPressAtPoint:
        (CGPoint)viewPoint;

    Swift

    func tappableAnnotationsForLongPress(at viewPoint: CGPoint) -> [PSPDFAnnotation]
  • Used within tappableAnnotationsAtPoint: to expand the tap point to make tapping objects easier. By default the rect has a size of 30 pixels.

    Declaration

    Objective-C

    - (CGRect)hitTestRectForPoint:(CGPoint)viewPoint;

    Swift

    func hitTestRect(for viewPoint: CGPoint) -> CGRect
  • Can be used for manual tap forwarding.

    Declaration

    Objective-C

    - (BOOL)singleTappedAtViewPoint:(CGPoint)viewPoint;

    Swift

    func singleTapped(atViewPoint viewPoint: CGPoint) -> Bool
  • Called with the set of annotations that are now selected. Can be used to postprocess annotations or enforce user changes.

    Declaration

    Objective-C

    - (void)didSelectAnnotations:(nullable NSArray<PSPDFAnnotation *> *)annotations;

    Swift

    func didSelect(_ annotations: [PSPDFAnnotation]?)
  • Called with the set of annotations that were selected, but are no longer. Can be used to postprocess annotations or enforce user changes.

    Declaration

    Objective-C

    - (void)didDeselectAnnotations:
        (nonnull NSArray<PSPDFAnnotation *> *)annotations;

    Swift

    func didDeselect(_ annotations: [PSPDFAnnotation])
  • Get annotation rect (PDF coordinate space)

    Declaration

    Objective-C

    - (CGRect)rectForAnnotations:(nonnull NSArray<PSPDFAnnotation *> *)annotations;

    Swift

    func rect(for annotations: [PSPDFAnnotation]) -> CGRect
  • Render options that are used for the live-page rendering. (not for the cache) One way to use this would be to customize what annotations types will be rendered with the pdf. See PSPDFRenderOption for a list of options.

    Declaration

    Objective-C

    - (nonnull NSDictionary<PSPDFRenderOption, id> *)
    renderOptionsDictWithZoomScale:(CGFloat)zoomScale
                          animated:(BOOL)animated;

    Swift

    func renderOptionsDict(withZoomScale zoomScale: CGFloat, animated: Bool) -> [PSPDFRenderOption : Any]
  • View for the selected annotation. Created and destroyed on the fly.

    Declaration

    Objective-C

    @property (readonly, nonatomic, nullable)
        PSPDFResizableView *annotationSelectionView;

    Swift

    var annotationSelectionView: PSPDFResizableView? { get }
  • Helper to properly place an annotation.

    Declaration

    Objective-C

    - (void)centerAnnotation:(nonnull PSPDFAnnotation *)annotation
              aroundPDFPoint:(CGPoint)pdfPoint;

    Swift

    func center(_ annotation: PSPDFAnnotation, aroundPDFPoint pdfPoint: CGPoint)
  • Load page annotations from the PDF.

    Declaration

    Objective-C

    - (void)loadPageAnnotationsAnimated:(BOOL)animated
                      blockWhileParsing:(BOOL)blockWhileParsing;

    Swift

    func loadPageAnnotations(animated: Bool, blockWhileParsing: Bool)
  • Computes a scale value suitable for computation of the line width to use during drawing and selection.

    Declaration

    Objective-C

    @property (readonly, nonatomic) CGFloat scaleForPageView;

    Swift

    var scaleForPageView: CGFloat { get }
  • Change notification processing.

    Declaration

    Objective-C

    - (void)annotationsAddedNotification:(nonnull NSNotification *)notification;

    Swift

    func annotationsAddedNotification(_ notification: Notification)
  • Undocumented

    Declaration

    Objective-C

    - (void)annotationsRemovedNotification:(NSNotification *)notification NS_REQUIRES_SUPER;

    Swift

    func annotationsRemovedNotification(_ notification: Notification)
  • Undocumented

    Declaration

    Objective-C

    - (void)annotationChangedNotification:(NSNotification *)notification NS_REQUIRES_SUPER;

    Swift

    func annotationChangedNotification(_ notification: Notification)
  • Customize if the annotation object should also transform the properties.

    Declaration

    Objective-C

    - (BOOL)shouldScaleAnnotationWhenResizing:(nonnull PSPDFAnnotation *)annotation
                               usesResizeKnob:(BOOL)usesResizeKnob;

    Swift

    func shouldScaleAnnotation(whenResizing annotation: PSPDFAnnotation, usesResizeKnob: Bool) -> Bool
  • Customize annotation selection view.

    Declaration

    Objective-C

    - (void)updateAnnotationSelectionView;

    Swift

    func updateAnnotationSelectionView()