Flatten Annotations in Flutter
PSPDFKit for Flutter allows you to create a new document with processed (embedded, flattened, removed, or printed) annotations using the
processAnnotations(String type, String processingMode, String destinationPath) function.
This guide shows how to use the
processAnnotations() function and its parameters.
The processing mode parameter is a string that specifies how PSPDFKit should include annotations in the resulting document.
||The annotation will be flattened. Its visual representation is kept intact, but it can no longer be modified. The annotation object is removed from the document.|
||The annotation will be removed.|
||The annotation will be embedded into the resulting document, allowing it to still be modified.|
|Processes the document for printing. Flattens annotations that can be printed and removes the remaining ones.|
The annotation type parameter is a string 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
The destination path parameter 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.
A typical call of the
processAnnotations function would look like this:
// First open a PDF file using `present()`. await Pspdfkit.processAnnotations('all', 'flatten', 'PDFs/export.pdf');