How Do I Change How Links Are Opened?

By default, links in a PDF are opened in Safari. However, you can change this behavior and instead open them in various ways, including an inline web view controller, an inline browser, first showing an alert before opening a link, or not opening a link at all.

You can change how links are handled by setting the linkAction property in the configuration of your view controller:

let controller = PDFViewController(document: document) {
    // Change link action to use inline browser.
    $0.linkAction = .inlineBrowser
}