Skip to content

Import and Export

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.

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

Import Annotations

You can import an XFDF file into the document by calling the importAnnotations(xfdfFile) method.

  • The parameter xfdfFile specifies the path of the XFDF file to be imported.
  • On the Android platform, this path can be:
    • A file Uri
    • A file path
    • A file located in the assets directory

Example code:

dart
CPDFReaderWidget(
          document: documentPath,
          configuration: CPDFConfiguration(),
          onCreated: (controller) {
            setState(() {
              this.controller = controller;
            });
          },
        )

bool result = await controller.document.importAnnotations(xfdfFile);

Export Annotations

You can export the current annotations in the document to an XFDF file by calling the exportAnnotations() method:

  • This method does not require a path parameter. The system will automatically generate and return the exported XFDF file path.

Example code:

dart
CPDFReaderWidget(
          document: documentPath,
          configuration: CPDFConfiguration(),
          onCreated: (controller) {
            setState(() {
              this.controller = controller;
            });
          },
        )

String xfdfFilePath = await controller.document.exportAnnotations();