Configure PDF View Controllers on iOS

A PDFConfiguration defines the behavior of a PDFViewController. It uses the builder pattern from PDFConfigurationBuilder to create an immutable copy using a closure.

The following code demonstrates a typical use case:

let document = Document(url: documentURL)
// The configuration building closure is passed to the `Document` initializer as a trailing closure.
let controller = PDFViewController(document: document) {
    $0.thumbnailBarMode = .none
    $0.shouldShowUserInterfaceOnViewWillAppear = false
    $0.isPageLabelEnabled = false
PSPDFDocument *document = [[PSPDFDocument alloc] initWithURL:documentURL];
PSPDFViewController *controller = [[PSPDFViewController alloc] initWithDocument:document configuration:[PSPDFConfiguration configurationWithBuilder:^(PSPDFConfigurationBuilder *builder) {
    builder.thumbnailBarMode = PSPDFThumbnailBarModeNone;
    builder.shouldShowUserInterfaceOnViewWillAppear = NO;
    builder.pageLabelEnabled = NO;

PDFViewController contains a shortcut to create and set a new PDFConfiguration object — updateConfiguration(builder:) — based on the current settings. After setting the new configuration object, the view controller will automatically invoke reloadData() to refresh its state.

Certain properties can be updated without a full state reload using updateConfigurationWithoutReloading(builder:). Be careful though, since PSPDFKit doesn’t warn you if you change a property that would require a state reload, as the view controller could get into an invalid state using this method.

Here’s an example:

controller.updateConfigurationWithoutReloading {
    $0.isTextSelectionEnabled = !isAutoplaying
    $0.isScrollOnEdgeTapEnabled = !isAutoplaying
[controller updateConfigurationWithoutReloadingWithBuilder:^(PSPDFConfigurationBuilder *builder) {
    builder.textSelectionEnabled = !self.isAutoplaying;
    builder.scrollOnEdgeTapEnabled = !self.isAutoplaying;