Import and export PDF annotations from XFDF files in Flutter
XFDF is an XML-like Adobe standard for encoding annotations and form field values. It’s compatible with Adobe Acrobat and several other third-party frameworks.
Nutrient Flutter SDK supports reading and writing XFDF(opens in a new tab) to import and export annotations on Android, iOS, and Web. Access the annotation manager through the loaded document’s controller (controller.document.annotations), which is available from the NutrientDocumentView onControllerReady callback.
Importing XFDF
Pass the XFDF data to importXfdf. This method takes the XFDF data as a string, not a file path, so read the file’s contents into a string first:
final ok = await controller.document.annotations.importXfdf(xfdfString);Exporting XFDF
exportXfdf returns the current annotations as an XFDF string. In version 6.0.0, this replaced the earlier file-path API. Persist the string to a file if you need one:
final xfdf = await controller.document.annotations.exportXfdf();All annotations — both saved and unsaved — will be exported.