PSPDFConfiguration


A PSPDFConfiguration defines the behavior of a PSPDFViewController. It uses the builder pattern via 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.shouldShowHUDOnViewWillAppear = false
    builder.isPageLabelEnabled = false
})
Copy
1
2
3
4
5
6
PSPDFDocument *document = [PSPDFDocument documentWithURL:documentURL];
PSPDFViewController *controller = [[PSPDFViewController alloc] initWithDocument:document configuration:[PSPDFConfiguration configurationWithBuilder:^(PSPDFConfigurationBuilder *builder) {
    builder.thumbnailBarMode = PSPDFThumbnailBarModeNone;
    builder.shouldShowHUDOnViewWillAppear = NO;
    builder.pageLabelEnabled = NO;
}]];

PSPDFViewController contains a shortcut to create and set a new PSPDFConfiguration object with all current setting pre-set 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 via updateConfigurationWithoutReloadingWithBuilder:. Be careful 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.

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;
}];
Was this page helpful? We're happy to answer any questions.