PSPDFPageView


@interface PSPDFPageView
    : UIView <PSPDFRenderTaskDelegate, PSPDFResizableViewDelegate,
              PSPDFAnnotationGridViewControllerDelegate, UIScrollViewDelegate>

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.

  • 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<PSPDFAnnotationViewProtocol> *)annotationViewForAnnotation:
        (nonnull PSPDFAnnotation *)annotation;

    Swift

    func annotationView(for annotation: PSPDFAnnotation) -> UIView?
  • 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 PSPDFAnnotationViewProtocol, 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 }
  • Calculated scale. Readonly.

    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. - note: pageBounds usually is PSPDFPageView bounds.

    Declaration

    Objective-C

    - (CGPoint)convertViewPointToPDFPoint:(CGPoint)viewPoint;

    Swift

    func convertPoint(toPDFPoint viewPoint: CGPoint) -> CGPoint
  • Convert a PDF point to the corresponding view point. - note: pageBounds usually is PSPDFPageView bounds.

    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 parent PSPDFScrollView if available. (zoom controller) - note: this only lets you access the scrollView if it’s in the view hierarchy. If we use pageCurl mode, we have a global scrollView which can be accessed with pdfController.pagingScrollView

    Declaration

    Objective-C

    @property (readonly, nonatomic, nullable) PSPDFScrollView *scrollView;

    Swift

    var scrollView: PSPDFScrollView? { get }
  • Returns an array of UIView PSPDFAnnotationViewProtocol objects currently in the view hierarchy.

    Declaration

    Objective-C

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

    Swift

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

    Declaration

    Objective-C

    @property (readonly, atomic) NSUInteger pageIndex;

    Swift

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

    Declaration

    Objective-C

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

    Swift

    var pageInfo: PSPDFPageInfo? { get }
  • Return YES if the pdfPage is displayed in a double page mode setup on the trailing side.

    Declaration

    Objective-C

    @property (readonly, getter=isTrailingPage, nonatomic) BOOL trailingPage;

    Swift

    var isTrailingPage: Bool { get }
  • Return YES if the pdfPage is displayed in a double page mode setup on the right side.

    Declaration

    Objective-C

    @property (readonly, getter=isRightPage, nonatomic) BOOL rightPage;

    Swift

    var isRightPage: Bool { get }
  • Undocumented

    Declaration

    Objective-C

    
    @interface PSPDFPageView
        : UIView <PSPDFRenderTaskDelegate, PSPDFResizableViewDelegate,
                  PSPDFAnnotationGridViewControllerDelegate, UIScrollViewDelegate>
  • Undocumented

    Declaration

    Objective-C

    
    @interface PSPDFPageView
        : UIView <PSPDFRenderTaskDelegate, PSPDFResizableViewDelegate,
                  PSPDFAnnotationGridViewControllerDelegate, UIScrollViewDelegate>
  • Currently selected annotations (selected by a tap; showing a menu)

    Declaration

    Objective-C

    @property (readwrite, copy, nonatomic, null_resettable)
        NSArray<__kindof 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)