Exporting a PDF in MAUI

When exporting PDF documents in MAUI, you have the option to customize the export process using the IExportConfiguration interface to meet your specific requirements.

Introduction to Export Configurations

IExportConfiguration is an interface that represents the configuration with which a document will be exported. It offers several properties you can set to modify the export behavior. You can create an object of export configuration from the document using the <IDocument>.CreateExportConfiguration() method. If you choose to pass null instead of an object to the export method, the default configuration will be applied automatically.

The following sections cover the key properties of the IExportConfiguration interface.

ExcludeAnnotations (Default: False)

The ExcludeAnnotations property allows you to exclude annotations from an exported document. By setting it to true, you can create a document without any annotations:

IExportConfiguration exportConfig = _document.CreateExportConfiguration();
exportConfig.ExcludeAnnotations = true;

ExportForPrinting (Default: False)

When set to true, the ExportForPrinting property excludes annotations that have the NoPrint flag set from the exported document. This is useful when you want to create a print-ready document without certain annotations.

Note that currently, we can only set the NoPrint flag on annotations using advance API access:

IExportConfiguration exportConfig = _document.CreateExportConfiguration();
exportConfig.ExportForPrinting = true;

ExportIncrementally (Default: False, but True for Digitally Signed Documents)

When persisting changes to an open document, two main strategies are available: incremental saving and full saving.

Incremental saving consists of appending new changes to the end of a document while keeping the previous versions of it intact, which is useful when working with digitally signed documents, as digital signatures are invalidated if the integrity of a signed content is compromised.

Full saving, on the other hand, rewrites an entire document instead of appending changes at the end of it. This prevents the document file size from growing on every revision, but it’s slower than incremental saving.

PSPDFKit for MAUI uses full saving by default, except for with digitally signed documents, which use incremental saving by default if the Digital Signatures component is present in the license. If you wish to use incremental saving instead, set the ExportIncrementally flag to true when calling the _document.ExportDocumentAsync method:

IExportConfiguration exportConfig = _document.CreateExportConfiguration();
exportConfig.ExportIncrementally = true;

Setting ExportIncrementally when Flatten is already set will result in an InvalidOperationException.

Flatten (Default: False)

When set to true, this property visually embeds annotations and form fields in a document, making them non-editable in the future:

IExportConfiguration exportConfig = _document.CreateExportConfiguration();
exportConfig.Flatten = true;

Setting Flatten when ExportIncrementally is already set will result in an InvalidOperationException.


The Permissions property allows you to set the user and owner password on an exported document. This is particularly useful when you want to restrict access or actions on the document:

IExportConfiguration exportConfig = _document.CreateExportConfiguration();
exportConfig.Permissions.UserPassword = "userPassword";
exportConfig.Permissions.OwnerPassword = "ownerPassword";
exportConfig.Permissions.PermissionFlags = AnnotationsAndForms | Assemble // set the permissions here;