Link Annotations


PSPDFKit supports all common types of link annotations. (Page Links, Web/Email links). Tapping such a link will automatically invoke the saved action (see: PDF Actions) and invoke the correct task, such as changing the page or displaying another document/opening a URL.

By default PSPDFKit will parse annotations, including links, from the document. You can also manually create link annotations and add them to the document (see Programmatically creating annotations and add objects of the type PSPDFLinkAnnotation in the API documentation).

PSPDFLinkAnnotation can be initialized with an PSPDFAction subclass. The most used subclasses will be PSPDFURLAction for web links and PSPDFGoToAction for page links.

Style

Links will have a border to indicate that they are tappable. This can be changed via UIAppearance:

Copy
1
2
// Customize the link annotation's appearance
PSPDFLinkAnnotationView.appearance().borderColor = .blue
Copy
1
2
// Customize the link annotation's appearance
[[PSPDFLinkAnnotationView appearance] setBorderColor:UIColor.blueColor];

PSPDFKit can optionally analyze the page contents and automatically add links to URLs and phone numbers. This is slightly expensive since text needs to be parsed and analyzed, but it's done in a background process so in most cases it is not noticeably slower. Set autodetectTextLinkTypes to PSPDFTextCheckingTypeAll to enable detection for all supported types.

Was this page helpful? We're happy to answer any questions.