# Importing XFDF has failed

**URL:** https://pdfjs.community/t/importing-xfdf-has-failed/1006
**Category:** Technical Support
**Created:** [September 29, 2021, 6:43am UTC](https://pdfjs.community/t/importing-xfdf-has-failed/1006 "2021-09-29T06:43:58Z")
**Posts on this page:** 1
**Showing post:** 1

<div class="post-metadata">

### Author: ![crossbim001](https://avatars.discourse-cdn.com/v4/letter/c/d9b06d/32.png) [@crossbim001](https://pdfjs.community/u/crossbim001)
#### Post date: [September 29, 2021, 6:43am UTC](https://pdfjs.community/t/importing-xfdf-has-failed/1006/1 "2021-09-29T06:43:58Z")

</div>

PDF.js Express Version: 8.x.x

**We exported annotations as XFDFs, but could not import XFDFs. We tried to pass xfdfString value to annotationManager.importAnnotCommand(xfdfString) function. The result is empty array. We would like to know how we could import XFDFs.**

Here is what we referenced.

> **[Import & Export Annotations using Files with PDF.js Express | Documentation](https://pdfjs.express/documentation/annotation/import-export/files)**

**The below code is about exporting XFDFs.**

\<?xml version="1.0" encoding="UTF-8" ?\> 

Here is importing code:

```javascript
useEffect(() => {
    WebViewer(
      {
        path: '../../../webviewer/lib',
        initialDoc: 'https://s3.ap-northeast-2.amazonaws.com/crossxxx/xxx/drive/wGmxxxx.pdf',
      },
      viewer.current
    ).then((instance) => {
      const { annotationManager, documentViewer } = instance.Core

      // load the annotation data as a transaction command
      fetch('https://apixxx.crossxxxx.cxxxx/pdf-web/715', {
        method: 'GET',
      }).then((response) => {
        if (response.status === 200) {
          response.text().then(async (xfdfString) => {
            console.log('xfdfString', xfdfString)
            // <xfdf>
            // <add>
            // <text subject="Comment" page="0" color="#FFE6A2" ... />
            // </add>
            // <modify />
            // <delete />
            // </xfdf>
            const annotations = await annotationManager.importAnnotCommand(xfdfString) // empty array is returned
            console.log('annotations', annotations)

            annotations.forEach((annotation) => {
              annotationManager.redrawAnnotation(annotation)
            })
          })
        }
      })
    })
},[])

```

Please let us know what to do.

Thanks in advance,  
Heejung

---

_[View the full topic](https://pdfjs.community/t/importing-xfdf-has-failed/1006)._
