PSPDFLinkAnnotation


@interface PSPDFLinkAnnotation : PSPDFAnnotation

The PSPDFLinkAnnotation represents both classic PDF page/document/web links, and more types not supported by other PDF readers (video, audio, image, etc)

PSPDFKit will automatically figure out the type for PDF link annotations loaded from a document, based on the file type. (mp4 belongs to PSPDFLinkAnnotationVideo; a YouTube-URL to PSPDFLinkAnnotationYouTube, etc)

If you create a PSPDFLinkAnnotation at runtime, be sure to set the correct type and use the URL parameter for your link. boundingBox defines the frame, in PDF space coordinates.

If you want to customize how links look in the PDF, customize PSPDFLinkAnnotationView’s properties. There’s currently no mapping between color/lineWidth/etc and the properties of the view. This might change in a future release.

  • Designated initializer for custom, at runtime created PSPDFLinkAnnotations.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithLinkAnnotationType:
        (PSPDFLinkAnnotationType)linkAnnotationType;

    Swift

    init(linkAnnotationType: PSPDFLinkAnnotationType)
  • Initialize with an action.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithAction:(nonnull PSPDFAction *)action;

    Swift

    init(action: PSPDFAction)
  • Initialize link annotation with target URL.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithURL:(nonnull NSURL *)URL;

    Swift

    init(url URL: URL)
  • PSPDFKit addition - will be updated if the pspdfkit:// protocol is detected.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) PSPDFLinkAnnotationType linkType;

    Swift

    var linkType: PSPDFLinkAnnotationType { get set }
  • The associated PDF action that will be executed on tap. Will update the linkType when set. - note: Only evaluated if isMultimediaExtension returns NO.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic, nullable) PSPDFAction *action;

    Swift

    var action: PSPDFAction? { get set }
  • Convenience cast. Will return the URL action if action is of type PSPDFActionTypeURL, else nil.

    Declaration

    Objective-C

    @property (readonly, nonatomic, nullable) PSPDFURLAction *URLAction;

    Swift

    var urlAction: PSPDFURLAction? { get }
  • URL

    Convenience method, gets the URL if action is a PSPDFURLAction.

    Declaration

    Objective-C

    @property (readonly, copy, nonatomic, nullable) NSURL *URL;

    Swift

    var url: URL? { get }
  • Will be YES if this is a regular link or a multimedia link annotation that should be displayed as link. (e.g. if isPopover/isModal is set to yes)

    Declaration

    Objective-C

    @property (readonly, nonatomic) BOOL showAsLinkView;

    Swift

    var showAsLinkView: Bool { get }
  • Returns YES if this link is specially handled by PSPDFKit. Returns true for any linkType >= PSPDFLinkAnnotationVideo && linkType <= PSPDFLinkAnnotationBrowser.

    Declaration

    Objective-C

    @property (readonly, getter=isMultimediaExtension, nonatomic)
        BOOL multimediaExtension;

    Swift

    var isMultimediaExtension: Bool { get }
  • Show or hide controls. Valid for PSPDFLinkAnnotationVideo, PSPDFLinkAnnotationAudio and PSPDFLinkAnnotationBrowser. Defaults to YES. Some controls will add alternative ways to control if this is disabled. e.g. Videos can be paused via touch on the view if this is set to NO. Websites will not receive touches if controlsEnabled is set to NO.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) BOOL controlsEnabled;

    Swift

    var controlsEnabled: Bool { get set }
  • Autoplay video/audio. Only valid for PSPDFLinkAnnotationVideo and PSPDFLinkAnnotationAudio. Defaults to NO.

    Declaration

    Objective-C

    @property (getter=isAutoplayEnabled, assign, readwrite, nonatomic)
        BOOL autoplayEnabled;

    Swift

    var isAutoplayEnabled: Bool { get set }
  • Loop media. Only valid for PSPDFLinkAnnotationVideo and PSPDFLinkAnnotationAudio. Defaults to NO.

    Declaration

    Objective-C

    @property (getter=isLoopEnabled, assign, readwrite, nonatomic) BOOL loopEnabled;

    Swift

    var isLoopEnabled: Bool { get set }
  • Allow fullscreen presentation of the media item. Defaults to YES.

    Declaration

    Objective-C

    @property (getter=isFullscreenEnabled, assign, readwrite, nonatomic)
        BOOL fullscreenEnabled;

    Swift

    var isFullscreenEnabled: Bool { get set }
  • Used for the preview string when the user long-presses on a link annotation. Forwards to action.localizedDescription.

    Declaration

    Objective-C

    @property (readonly, nonatomic, nullable) NSString *targetString;

    Swift

    var targetString: String? { get }