Display and manipulate PDF documents using PDFKit. Use when embedding PDFView to show PDF files, creating or modifying PDFDocument instances, adding annotations (highlights, notes, signature widgets), extracting text with PDFSelection, navigating pages, generating thumbnails, filling PDF forms, or wrapping PDFView in SwiftUI.
A Swift reference for displaying and manipulating PDF documents with Apple's PDFKit, targeting Swift 6.3 and iOS 26+ (with PDFKit available from iOS 11 and across iPadOS, Mac Catalyst, macOS, tvOS, and visionOS). It requires no entitlements or Info.plist entries. The central UI type is PDFView, a UIView subclass that renders content and handles zoom, scroll, text selection, and page navigation out of the box, configurable through display modes (singlePage, singlePageContinuous, twoUp, twoUpContinuous), auto-scaling with min and max scale factors, page breaks, page shadows, and interpolation quality.
Document handling centers on PDFDocument, which loads from a URL or Data or can be created empty, unlocks password-protected files via isLocked and unlock(withPassword:), writes out (optionally with owner and user password options or as a data representation), and manipulates zero-based pages through insert, removePage, and exchangePage. Navigation includes go(to:), sequential and first/last helpers, back/forward history, PDFDestination points, and PDFViewPageChanged notifications. Text features cover synchronous findString search, asynchronous search via PDFDocumentDelegate, the iOS 16+ system find bar, text extraction (document and page string and attributedString, plus region-based selection), and highlighting search results through highlightedSelections.
Annotations are created with PDFAnnotation(bounds:forType:withProperties:) and added to a PDFPage, with worked examples for highlight, sticky text note, free text, and link annotations, plus the full list of subtypes (highlight, underline, strikeOut, text, freeText, ink, link, line, square, circle, stamp, widget). It also covers PDFThumbnailView for a linked thumbnail strip, SwiftUI integration, and includes common-mistakes and review-checklist sections. Use it when embedding a PDF viewer or programmatically reading, searching, or annotating PDFs on Apple platforms.
PDFView for display, PDFDocument for loading and manipulation, PDFPage, PDFAnnotation, PDFSelection for text search and selection, and PDFThumbnailView for thumbnails.
No. PDFKit requires no entitlements or Info.plist entries; you simply import PDFKit.
Check document.isLocked and call document.unlock(withPassword:); if it returns false, show a password prompt. Documents can also be written out with owner and user password options.
Synchronously with document.findString(_:withOptions:), which returns PDFSelections, or asynchronously via PDFDocumentDelegate; the iOS 16+ system find bar is enabled with pdfView.isFindInteractionEnabled.
Annotations are created via PDFAnnotation(bounds:forType:withProperties:), with subtypes including highlight, underline, strikeOut, text, freeText, ink, link, line, square, circle, stamp, and widget.
Quick Setup:
.claude/skills/Repository
dpearson2699/swift-ios-skills