PSPDFConfiguration

A PSPDFConfiguration defines the behavior of a PSPDFViewController. It uses the builder pattern from PSPDFConfigurationBuilder to create an immutable copy via a block.

A typical use case is the following:

Copy
1
2
3
4
5
6
let document = PSPDFDocument(url: documentURL)
let controller = PSPDFViewController(document: document, configuration: PSPDFConfiguration { builder in
    builder.thumbnailBarMode = .none
    builder.shouldShowUserInterfaceOnViewWillAppear = false
    builder.isPageLabelEnabled = false
})
Copy
1
2
3
4
5
6
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;
}]];

PSPDFViewController contains a shortcut to create and set a new PSPDFConfiguration object with all current settings set up in advance up via updateConfigurationWithBuilder:. 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 updateConfigurationWithoutReloadingWithBuilder:. Be careful though, since PSPDFKit doesn't warn you if you change a property that would require a state reload - the view controller could get into an invalid state using this method.

Example:

Copy
1
2
3
4
controller.updateConfigurationWithoutReloading { builder in
    builder.isTextSelectionEnabled = !isAutoplaying
    builder.isScrollOnTapPageEndEnabled = !isAutoplaying
}
Copy
1
2
3
4
[controller updateConfigurationWithoutReloadingWithBuilder:^(PSPDFConfigurationBuilder *builder) {
    builder.textSelectionEnabled = !self.isAutoplaying;
    builder.scrollOnTapPageEndEnabled = !self.isAutoplaying;
}];