On this page
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 ReactNative 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:
tsx
const pdfReaderRef = useRef<CPDFReaderView>(null);
<CPDFReaderView
ref={pdfReaderRef}
document={samplePDF}
configuration={ComPDFKit.getDefaultConfig({
})}/>
const importResult = await pdfReaderRef.current?.importAnnotations('xxx.xfdf');
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:
tsx
const pdfReaderRef = useRef<CPDFReaderView>(null);
<CPDFReaderView
ref={pdfReaderRef}
document={samplePDF}
configuration={ComPDFKit.getDefaultConfig({
})}/>
const exportXfdfFilePath = await pdfReaderRef.current?.exportAnnotations();