PSPDFKit 1.1 MAUI Migration Guide
This article provides a set of guidelines for migrating from version 1.0 to version 1.1 of PSPDFKit for MAUI.
Opening a Document
With the introduction of customization APIs for PSPDFKit Viewer, we updated the method signature for opening a document. The new signature now accepts a configuration with which the viewer should be loaded. The new method signatures are as follows:
Task<IDocument> LoadDocumentFromAssetsAsync( string assetDocumentPath, IViewerConfiguration configuration); Task<IDocument> LoadDocumentFromBufferAsync( byte[] buffer, IViewerConfiguration configuration); Task<IDocument> LoadDocumentFromBase64StringAsync( string documentAsBase64String, IViewerConfiguration configuration); Task<IDocument> LoadDocumentFromURLAsync( string url, IViewerConfiguration configuration); Task<IDocument> LoadDocumentAsync( string fullPath, IViewerConfiguration configuration);
The IViewerConfiguration
interface is used to configure the viewer. You can create a configuration using the IController.CreateViewerConfiguration
method. Viewer configuration that’s passed to the methods is optional. If you want to use the default configuration, you can pass null
.
Viewer configuration cannot be modified once the viewer is loaded. If you want to change the configuration, you need to reload the viewer with the new configuration.
Here’s an example of how to open a document from application assets:
string assetDocumentPath = "subFolder/document.pdf"; // Path to the document in the Assets folder. try { var config = PSPDFKitController.CreateViewerConfiguration(); config.ToolbarPlacement = ToolbarPlacement.Bottom; await PSPDFKitController.LoadDocumentFromAssetsAsync(assetDocumentPath, config); } catch (Exception ex) { // Handle exception. }