Customizing Download/Export Buttons in Our PDF Viewer

The built-in download button can be activated by adding it to MainToolbar.ToolbarItems:

PSPDFKitController.MainToolbar.ToolbarItems.Add(new ExportPDFButton());

If you need more fine-grained control over the download operation, you can easily add your own download button to PSPDFKit for MAUI with IDocument.ExportDocumentAsync and the possibility of customizing the toolbar:

var downloadButton = new CustomMainToolbarButton("download-button")
{
    Icon = "download.svg",
    Tooltip = "Download"
};

downloadButton.Clicked += async (s, e) =>
{
    var exportedDocumentContent = await _document.ExportDocumentAsync(
      _document.CreateExportConfiguration());
    var result = await FileSaver.Default.SaveAsync(
        "download.pdf", new MemoryStream(exportedDocumentContent), CancellationToken.None);
};

PSPDFKitController.MainToolbar.ToolbarItems.Add(downloadButton);

Hiding the Download Button

You can remove the download button from the toolbar by getting the array of current toolbar items via MainToolbar.ToolbarItems and removing the item from the collection:

var downloadButton = PSPDFKitController.MainToolbar.ToolbarItems.FirstOrDefault(item => item is ExportPDFButton);
if (downloadButton == null)
{
    return;
}

PSPDFKitController.MainToolbar.ToolbarItems.Remove(downloadButton);