Import and Export PDF Annotations from XFDF Files in Flutter

XFDF is an XML-like standard from Adobe XFDF for encoding annotations and form field values. It’s compatible with Adobe Acrobat and several other third-party frameworks.

PSPDFKit for Flutter supports both reading and writing XFDF to import and export annotations. This guide shows how to import and export annotations using the XFDF format.


Importing and exporting XFDF in Flutter is only supported by the iOS platform at the moment. Support for Android is coming soon.

Importing XFDF

You can import annotations from an existing XFDF file to a document simply by calling importXfdf(xfdfPath). The xfdfPath parameter here is the path of the XFDF file that needs to be imported. Note that the file should first be copied from assets to the temporary directory:

// First open a PDF file using `present()`.
await pspdfkitWidgetController.importXfdf(xfdfPath);

Exporting XFDF

You can export the current annotations of a document to an XFDF file by calling exportXfdf(xfdfPath). The XFDF file will be saved at the given path in the document directory:

// First open a PDF file using `present()`.
final path = 'Data/test.xfdf';
await pspdfkitWidgetController.exportXfdf(path);

All annotations — both saved and unsaved — will be exported.