PSPDFLinkAnnotation

Objective-C


@interface PSPDFLinkAnnotation : PSPDFAnnotation <PSPDFOverridable>

Swift

class LinkAnnotation : Annotation, Overridable

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: LinkAnnotation.Kind)
  • Initialize with an action.

    Declaration

    Objective-C

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

    Swift

    init(action: Action)
  • 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 PSPDFLinkAnnotationType linkType;

    Swift

    var linkType: LinkAnnotation.Kind { 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 (nullable) PSPDFAction *action;

    Swift

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

    Declaration

    Objective-C

    @property (readonly, nullable) PSPDFURLAction *URLAction;

    Swift

    var urlAction: PSPDFURLAction? { get }
  • URL

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

    Declaration

    Objective-C

    @property (copy, readonly, 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) 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) 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 BOOL controlsEnabled;

    Swift

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

    Declaration

    Objective-C

    @property (atomic, assign, unsafe_unretained, readwrite,
              getter=isAutoplayEnabled) 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) BOOL loopEnabled;

    Swift

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

    Declaration

    Objective-C

    @property (atomic, assign, unsafe_unretained, readwrite,
              getter=isFullscreenEnabled) 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, nullable) NSString *targetString;

    Swift

    var targetString: String? { get }