Import and Export PDF Annotations from XFDF Files in Flutter
XFDF is an XML-like standard from Adobe XFDF for encoding annotations and forms. 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.
ℹ️ Note: Importing and exporting XFDF in Flutter is only supported by the iOS platform at the moment. Support for Android is coming soon.
You can import annotations from an existing XFDF file to a document simply by calling
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 Pspdfkit.importXfdf(xfdfPath);
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 Pspdfkit.exportXfdf(path);
ℹ️ Note: All annotations — both saved and unsaved — will be exported.