Import and Export Annotations from XFDF Files on React Native
XFDF is an XML-based standard from Adobe XFDF (ISO 19444-1:2016) for encoding annotations and form field values. An XFDF file will contain a snapshot of a PDF document’s annotations and form field values. It doesn’t include the form elements or the form fields themselves — only the filled values. It’s compatible with Adobe Acrobat and several other third-party frameworks.
![]()
XFDF has various limitations. In most cases, using PSPDFKit Instant will result in a smaller file and better synchronization.
PSPDFKit for React Native supports both reading and writing XFDF.
Importing XFDF
You can import annotations and form field values from an XFDF file to a document like so:
// Reference the XFDF file from the application's documents directory. const xfdfImport = Platform.OS === 'ios' ? RNFS.DocumentDirectoryPath + '/' + 'import.xfdf' : 'file://' + RNFS.DocumentDirectoryPath + '/' + 'import.xfdf'; const result = await this.pdfRef.current ?.getDocument() .importXFDF(xfdfImport);
Exporting to XFDF
You can export annotations and form field values from a document to an XFDF file like so:
// Get a temporary location on the file system with write access to store the exported file. const xfdfOutput = RNFS.TemporaryDirectoryPath + '/test.xfdf'; const result = await this.pdfRef.current ?.getDocument() .exportXFDF(xfdfOutput);
Refer to the XFDF.tsx
example in the Catalog example project for a runnable example.
Exporting Annotations to XFDF via Adobe Acrobat
Adobe Acrobat can export annotations into XFDF. The export menu is part of the Comment tool and is accessed by opening the tool in the sidebar.
![Acrobat XFDF Export](/images/guides/shared/importing-exporting/xfdf-import-export/acrobat-xfdf-export-1-c2dda5ce.png)
You can access the export function by clicking the three dots and choosing Export All To Data File….
![Acrobat XFDF Export](/images/guides/shared/importing-exporting/xfdf-import-export/acrobat-xfdf-export-2-7c6f25eb.png)
-
At the bottom of the page, choose Acrobat XFDF Files.
-
Select the directory you wish to save the XFDF file to and name the file.
-
Click Save.
![Acrobat XFDF Export](/images/guides/shared/importing-exporting/xfdf-import-export/acrobat-xfdf-export-3-d89a6310.png)
A successful export will result in a file with an .xfdf
extension.
![Acrobat XFDF Export](/images/guides/shared/importing-exporting/xfdf-import-export/acrobat-xfdf-export-4-8877f4f8.png)
Importing Annotations to XFDF via Adobe Acrobat
The export function is part of the Comment tool and is accessed by clicking its icon.
![Acrobat XFDF Import](/images/guides/shared/importing-exporting/xfdf-import-export/acrobat-xfdf-import-1-b9da8ddf.png)
Click the three dots to open the import menu, and then click Import Data File….
![Acrobat XFDF Import](/images/guides/shared/importing-exporting/xfdf-import-export/acrobat-xfdf-import-2-4b6dec35.png)
Highlight the XFDF file you wish to import and click Select.
![Acrobat XFDF Import](/images/guides/shared/importing-exporting/xfdf-import-export/acrobat-xfdf-import-3-aba4dcb6.png)
The import function completes with the annotations being placed on the document.
![Acrobat XFDF Import](/images/guides/shared/importing-exporting/xfdf-import-export/acrobat-xfdf-import-4-7e4d58e7.png)
Adobe Acrobat Error Conditions
Error Description | Screenshot |
---|---|
Damaged/missing document body | ![]() |
Damaged/missing description tag | ![]() |
Missing document flag | ![]() |