Embed Annotations in a PDF File on Flutter

PSPDFKit for Flutter allows you to create a new document with embedded annotations using the processAnnotations(String type, String processingMode, String destinationPath) function.

ℹ️ Note: Annotation processing in Flutter is only supported by the iOS platform at the moment. Support for Android is coming soon.

Parameters

type is the annotation type parameter that specifies which annotation types PSPDFKit should process. See the list of all supported annotation types. To process all annotations (including forms), you need to set the value for the annotation type parameter to all or null.

processingMode is a string that specifies how PSPDFKit should include annotations in the resulting document. For embedding annotations while still allowing them to be modified, the mode should be set to embed. See our annotation flattening guide for a description of the other available processing modes.

destinationPath is a string that specifies the path where the resultant processed file will be stored. By default, it’ll be stored under the document directory.

❗ Important: Make sure you save all annotations before processing the document. For more details, please refer to our guide showing how to manually save annotations in a document.

Usage

Here’s how the function call for embedding all annotations into the PDF, which will be saved to PDFs/export.pdf, would look:

// First open a PDF file using `present()`.
await Pspdfkit.processAnnotations('all', 'embed', 'PDFs/export.pdf');