PSPDFPageView

Objective-C


@interface PSPDFPageView : UIView <PSPDFRenderTaskDelegate,
                                   PSPDFResizableViewDelegate, PSPDFOverridable>

Swift

class PDFPageView : UIView, RenderTaskDelegate, ResizableViewDelegate, Overridable

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 PDFPageView classes.

  • Unavailable

    Not the designated initializer

    Undocumented

    Declaration

    Objective-C

    PSPDF_EMPTY_INIT_UNAVAILABLE
  • Unavailable

    Not the designated initializer

    Undocumented

    Declaration

    Objective-C

    PSPDF_EMPTY_INIT_UNAVAILABLE
  • The attached presentation context.

    Declaration

    Objective-C

    @property (nonatomic, weak, readonly) id<PSPDFPresentationContext> _Nullable presentationContext;

    Swift

    weak var presentationContext: PresentationContext? { get }
  • Prepares the PDFPageView for reuse. Removes all unknown internal UIViews.

    Declaration

    Objective-C

    - (void)prepareForReuse;

    Swift

    func prepareForReuse()
  • 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()
  • Call whenever you change which annotations should be rendered. Updates overlay annotations and will remove any annotation selection. In most cases this should be called in combination with updateView.

    Declaration

    Objective-C

    - (void)updateAnnotationViewsAnimated:(BOOL)animated;

    Swift

    func updateAnnotationViews(animated: Bool)
  • Returns the existing subview used to display the given annotation — if any.

    This method will neither trigger loading annotations, nor create and insert a view for the given annotation. In addition, it will not return views that are scheduled to be removed.

    Note

    Unless they are currently selected, most annotations are rendered into the page. Whether or not a separate view will be used to display an annotation is controlled through its isOverlay property. In other words: This method always returns nil for annotations that return false from isOverlay and are not selected.

    Declaration

    Objective-C

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

    Swift

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

    Declaration

    Objective-C

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

    Swift

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

    Declaration

    Objective-C

    @property (nonatomic, readonly) 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 PDFPageView. 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) The contents of this view are managed. Additional subviews can be added, but they will be removed during page reuse. Subviews should respond to the PSPDFAnnotationPresenting, especially the annotation method.

    Declaration

    Objective-C

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

    Swift

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

    Declaration

    Objective-C

    @property (nonatomic, readonly) 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 (nonatomic) PSPDFRenderStatusView *_Nonnull renderStatusView;

    Swift

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

    Declaration

    Objective-C

    @property (nonatomic) CGFloat renderStatusViewOffset;

    Swift

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

    Declaration

    Objective-C

    @property (nonatomic, readonly) 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 (nonatomic, readonly) CGRect visibleRect;

    Swift

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

    Declaration

    Objective-C

    @property (nonatomic) UI_APPEARANCE_SELECTOR UIColor *highlightColor;

    Swift

    var highlightColor: UIColor { get set }
  • The color displayed on the page view before the PDF page is rendered.

    By default (assigned nil value), this value will be the best guess for the page background color, given the current render options (such as backgroundFill or invertRenderColor).

    This property is intended to be customized via -[PSPDFViewControllerDelegate pdfViewController:didConfigurePageView:forPageAtIndex:], UIAppearance or by subclassing this class.

    Declaration

    Objective-C

    @property (nonatomic, null_resettable) UIColor *placeholderColor;

    Swift

    var placeholderColor: UIColor! { get set }
  • The normalized PDF coordinate space of this view’s page. The origin of the space is the bottom-left corner of the displayed content.

    Use this property together with the methods in the UICoordinateSpace protocol to convert between PDF page and view coordinate spaces. For example to find the location of a UITouch in a page’s PDF coordinate space:

    let viewPoint = touch.location(in: pageView)
    let pdfPoint = pageView.convert(viewPoint, to: pageView.pdfCoordinateSpace)
    

    Note

    Important: Rectangles converted with this coordinate space must be well–formed! Do not, for example, try to convert something with a less–than–zero width…

    Read more in our Coordinate Space Conversions guide at https://pspdfkit.com/guides/ios/current/faq/coordinate-spaces/

    Declaration

    Objective-C

    @property (nonatomic, readonly) id<UICoordinateSpace> _Nonnull pdfCoordinateSpace;

    Swift

    var pdfCoordinateSpace: UICoordinateSpace { get }
  • Get the glyphs/words on a specific page.

    Declaration

    Objective-C

    - (nonnull NSDictionary<PSPDFObjectFinderType, id> *)
        objectsAtPoint:(CGPoint)viewPoint
               options:(nullable NSDictionary<PSPDFObjectFinderOption, NSValue *> *)
                           options;

    Swift

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

    Declaration

    Objective-C

    - (nonnull NSDictionary<PSPDFObjectFinderType, id> *)
        objectsAtRect:(CGRect)viewRect
              options:(nullable NSDictionary<PSPDFObjectFinderOption, NSValue *> *)
                          options;

    Swift

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

    Declaration

    Objective-C

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

    Swift

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

    Declaration

    Objective-C

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

    Swift

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

    Declaration

    Objective-C

    @property (nonatomic, readonly) PSPDFPageIndex pageIndex;

    Swift

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

    Declaration

    Objective-C

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

    Swift

    var pageInfo: PSPDFPageInfo? { get }
  • Currently selected annotations (selected by a tap; showing a menu)

    Declaration

    Objective-C

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

    Swift

    var selectedAnnotations: [Annotation]! { get set }
  • View for the selected annotation. Created and destroyed on the fly.

    Declaration

    Objective-C

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

    Swift

    var annotationSelectionView: ResizableView? { get }
  • Show signature menu.

    Declaration

    Objective-C

    - (void)showNewSignatureMenuAtRect:(CGRect)viewRect
                  signatureFormElement:
                      (nullable PSPDFSignatureFormElement *)signatureFormElement
                               options:
                                   (nullable NSDictionary<PSPDFPresentationOption,
                                                          id> *)options
                              animated:(BOOL)animated;

    Swift

    func showNewSignatureMenu(at viewRect: CGRect, signatureFormElement: PSPDFSignatureFormElement?, options: [PresentationOption : 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: Annotation.Kind) -> [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: [Annotation]) -> 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: Annotation, isFillColor: Bool)
  • By default, the markup tool menu is different depending on the currently available space, evaluated via the horizontal size class. In a regular size class we show all the style menu items in the menu, and in compact size class we show a ‘Style’ submenu. Override this to customize the behavior.

    Declaration

    Objective-C

    @property (nonatomic, readonly) 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)showMenuIfSelectedWithOption:(PSPDFContextMenuOption)contextMenuOption animated:(BOOL)animated;

    Swift

    func showMenuIfSelected(with contextMenuOption: ContextMenuOption, animated: Bool)
  • Shows a menu as appropriate for a context menu invocation at the given location.

    Declaration

    Objective-C

    - (void)showMenuForPoint:(CGPoint)location animated:(BOOL)animated;

    Swift

    func showMenu(for location: CGPoint, animated: Bool)
  • Shows an annotation menu as appropriate for a context menu invocation at the given location.

    Declaration

    Objective-C

    - (BOOL)showAnnotationMenuAtPoint:(CGPoint)viewPoint animated:(BOOL)animated;

    Swift

    func showAnnotationMenu(at viewPoint: CGPoint, animated: Bool) -> Bool
  • The method that checks if the receiver can create annotations, optionally showing a message with the PSPDFStatusHUD.

    Declaration

    Objective-C

    - (BOOL)canCreateAnnotationsShowMessage:(BOOL)showMessage;

    Swift

    func canCreateAnnotationsShowMessage(_ showMessage: Bool) -> Bool

    Parameters

    showMessage

    Specifies whether a message should be displayed if annotations cannot be created.

    Return Value

    true if annotations can be created, else false.

  • Deprecated

    Deprecated in PSPDFKit 9.1 for iOS. Call showMenuIfSelectedWithOption:animated: instead

    Undocumented

    Declaration

    Objective-C

    - (void)showMenuIfSelectedAnimated:(BOOL)animated allowPopovers:(BOOL)allowPopovers PSPDF_DEPRECATED_IOS(9.1, "Call `showMenuIfSelectedWithOption:animated:` instead");

    Swift

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

    Deprecated in PSPDFKit 9.1 for iOS. Call showMenuForAnnotations:targetRect:option:animated: instead

    Undocumented

    Declaration

    Objective-C

    - (void)showMenuForAnnotations:(NSArray<PSPDFAnnotation *> *)annotations targetRect:(CGRect)targetRect allowPopovers:(BOOL)allowPopovers animated:(BOOL)animated PSPDF_DEPRECATED_IOS(9.1, "Call `showMenuForAnnotations:targetRect:option:animated:` instead");

    Swift

    func showMenu(for annotations: [Annotation], targetRect: CGRect, allowPopovers: Bool, animated: Bool)
  • Associate an annotation with an annotation view

    Declaration

    Objective-C

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

    Swift

    func setAnnotation(_ annotation: Annotation, forAnnotationView annotationView: UIView & AnnotationPresenting)
  • Recall the annotation associated with an annotation view

    Declaration

    Objective-C

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

    Swift

    func annotation(forAnnotationView annotationView: UIView & AnnotationPresenting) -> Annotation?
  • 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 PDFPageView. 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: Annotation, 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: Annotation, 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: Annotation, animated: Bool)
  • Subclass to change shadow behavior.

    Declaration

    Objective-C

    - (void)updateShadowAnimated:(BOOL)animated;

    Swift

    func updateShadow(animated: Bool)
  • Used 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
  • 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:(nonnull NSArray<PSPDFAnnotation *> *)annotations;

    Swift

    func didSelect(_ annotations: [Annotation])
  • 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: [Annotation])
  • Get annotation rect (PDF coordinate space)

    Declaration

    Objective-C

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

    Swift

    func rect(for annotations: [Annotation]) -> 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 PSPDFRenderOptions for a list of options.

    Declaration

    Objective-C

    - (nonnull PSPDFRenderOptions *)renderOptionsWithZoomScale:(CGFloat)zoomScale
                                                      animated:(BOOL)animated;

    Swift

    func renderOptions(withZoomScale zoomScale: CGFloat, animated: Bool) -> RenderOptions
  • Helper to properly place an annotation.

    Declaration

    Objective-C

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

    Swift

    func center(_ annotation: Annotation, 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 (nonatomic, readonly) 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: Annotation, usesResizeKnob: Bool) -> Bool
  • Customize annotation selection view.

    Declaration

    Objective-C

    - (void)updateAnnotationSelectionView;

    Swift

    func updateAnnotationSelectionView()
  • Deprecated

    Deprecated in PSPDFKit 9.5 for iOS. Add your own gesture recognizer instead.

    Warning

    This subclassing hook method has been removed in PSPDFKit 9.5 and is no longer called. You must add your own tap gesture recognizer and use the interaction components to set up relationships with the internal gesture recognizrs. For more information, check out the migration guide: https://pspdfkit.com/guides/ios/current/migration-guides/pspdfkit-95-migration-guide

    Declaration

    Objective-C

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

    Swift

    func singleTapped(_ recognizer: UITapGestureRecognizer) -> Bool
  • Deprecated

    Deprecated in PSPDFKit 9.5 for iOS. Add your own gesture recognizer instead.

    Warning

    This subclassing hook method has been removed in PSPDFKit 9.5 and is no longer called. You must add your own tap gesture recognizer and use the interaction components to set up relationships with the internal gesture recognizrs. For more information, check out the migration guide: https://pspdfkit.com/guides/ios/current/migration-guides/pspdfkit-95-migration-guide

    Declaration

    Objective-C

    - (BOOL)singleTappedAtViewPoint:(CGPoint)viewPoint;

    Swift

    func singleTapped(atViewPoint viewPoint: CGPoint) -> Bool
  • Deprecated

    Deprecated in PSPDFKit 9.5 for iOS. Add your own gesture recognizer instead.

    Warning

    This subclassing hook has been removed in PSPDFKit 9.5 and is no longer called. You must add your own long press gesture recognizer and use the interaction components to set up relationships with the internal gesture recognizrs. For more information, check out the migration guide: https://pspdfkit.com/guides/ios/current/migration-guides/pspdfkit-95-migration-guide

    Declaration

    Objective-C

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

    Swift

    func longPress(_ recognizer: UILongPressGestureRecognizer) -> Bool
  • Deprecated

    Deprecated in PSPDFKit 9.5 for iOS. Use the interaction component activation conditions instead.

    Warning

    This subclassing hook method has been removed in PSPDFKit 9.5 and is no longer called. You must use the interaction component activation conditions to customize the behavior of selecting annotations. For more information, check out the migration guide: https://pspdfkit.com/guides/ios/current/migration-guides/pspdfkit-95-migration-guide

    Declaration

    Objective-C

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

    Swift

    func tappableAnnotations(at viewPoint: CGPoint) -> [Annotation]
  • Deprecated

    Deprecated in PSPDFKit 9.5 for iOS. Use the interaction component activation conditions instead.

    Warning

    This subclassing hook method has been removed in PSPDFKit 9.5 and is no longer called. You must use the interaction component activation conditions to customize the behavior of selecting annotations. For more information, check out the migration guide: https://pspdfkit.com/guides/ios/current/migration-guides/pspdfkit-95-migration-guide

    Declaration

    Objective-C

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

    Swift

    func tappableAnnotationsForLongPress(at viewPoint: CGPoint) -> [Annotation]