# Uncaught TypeError: object is not iterable, when loading annotation

**URL:** <https://pdfjs.community/t/uncaught-typeerror-object-is-not-iterable-when-loading-annotation/2071>\
**Category:** Technical Support\
**Created:** [September 29, 2022, 12:28am UTC](https://pdfjs.community/t/uncaught-typeerror-object-is-not-iterable-when-loading-annotation/2071 "2022-09-29T00:28:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![elliot](https://avatars.discourse-cdn.com/v4/letter/e/858c86/32.png) [@elliot](https://pdfjs.community/u/elliot)\
**Post date:** [September 29, 2022, 12:28am UTC](https://pdfjs.community/t/uncaught-typeerror-object-is-not-iterable-when-loading-annotation/2071/1 "2022-09-29T00:28:19Z")

</div>

**Which product are you using?**  
Express Plus

**PDF.js Express Version**  
8.7

**Detailed description of issue**  
I’m getting an error in the console, but things seem to work fine…

I’m loading an annotations with this code:

```javascript
const [annotation] = annotationManager.importAnnotCommand(annotationData.xfdf);
annotation.authorId = annotationData.authorId;
annotationManager.redrawAnnotation(annotation);
instance.fireEvent('updateAnnotationPermission', [annotation]);

```

It seems to be working just fine - the annotations are loaded into the PDF, and appear correctly.

However, in the developer console, I see this message:  
`Uncaught TypeError: object is not iterable (cannot read property Symbol(Symbol.iterator))`

Pointing to this line:  
`const [annotation] = annotationManager.importAnnotCommand(annotationData.xfdf);`

I grabbed this code from this guide #7.3, [Client Setup for Collaborating with PDF.js Express | Documentation](https://pdfjs.express/documentation/collaboration/realtime-collaboration-client)

What is causing this console error, even though it doesn’t seem like anything is broken?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex031/uploads/pdfjscommunity/original/1X/ffbcd25c7d423db8d5acd5db201c272f4db306dd.png) [@system](https://pdfjs.community/u/system)\
**Post date:** [September 29, 2022, 12:28am UTC](https://pdfjs.community/t/uncaught-typeerror-object-is-not-iterable-when-loading-annotation/2071/3 "2022-09-29T00:28:24Z")

</div>

**Hello, I’m Ron, an automated tech support bot 🤖**

While you wait for one of our customer support representatives to get back to you, please check out some of these documentation pages:

Guides:
- [Best practices for PDF.js Express - Load documents with loadDocument](https://pdfjs.express/documentation/learn-more/best-practices#load-documents-with-loaddocument)
- [Open a document, add annotations, download - 2. Listen for document load](https://pdfjs.express/documentation/use-case/upload-download.8#2.-listen-for-document-load)
- [Saving a document with annotations](https://pdfjs.express/documentation/basic-operations/save-document/save-with-annotations)

APIs:
- [Core.Annotations.WidgetAnnotation - addCustomAppearance(doc [, options])](https://pdfjs.express/api/Core.Annotations.WidgetAnnotation.html#addCustomAppearance__anchor)
- [PDF.js Express Utilities](https://pdfjs.express/api/utils/index.html#__anchor)
- [UndefinedannotationsLoaded](https://pdfjs.express/api/namespaces.list.html#event:annotationsLoaded__anchor)

Forums:
- [Error when loading xfdf annotations](https://pdfjs.community/t/error-when-loading-xfdf-annotations/1380/1)
- [How to render xfdf back into pdf](https://pdfjs.community/t/how-to-render-xfdf-back-into-pdf/2026/16)
- [Uncaught TypeError: Cannot read properties of undefined (reading ‘querySelector’)](https://pdfjs.community/t/uncaught-typeerror-cannot-read-properties-of-undefined-reading-queryselector/1952/1)

  
  

Share how you are using PDF.js Express in your organization you could win a **$500 Amazon gift card. All participants will receive 6 months of PDF.js Express+ for free**. Learn more [here](https://utm.guru/ueQNw)

---

<div class="post-metadata">

**Author:** ![tgordon](https://avatars.discourse-cdn.com/v4/letter/t/aca169/32.png) [@tgordon](https://pdfjs.community/u/tgordon)\
**Post date:** [September 29, 2022, 8:54pm UTC](https://pdfjs.community/t/uncaught-typeerror-object-is-not-iterable-when-loading-annotation/2071/4 "2022-09-29T20:54:00Z")

</div>

Hello elliot,

I suggest using the updated syntax:

```javascript
const [annotation] = await annotationManager.importAnnotations(annotationData.xfdf);
annotation.authorId = annotationData.authorId;
await annotationManager.redrawAnnotation(annotation);
instance.fireEvent('updateAnnotationPermission', [annotation]);

```

Best regards,  
Tyler Gordon  
Web Development Support Engineer  
PDFTron

Share how you are using PDF.js Express in your organization you could win a **$500 Amazon gift card. All participants will receive 6 months of PDF.js Express+ for free**. Learn more [here](https://utm.guru/ueQNw)

---

<div class="post-metadata">

**Author:** ![elliot](https://avatars.discourse-cdn.com/v4/letter/e/858c86/32.png) [@elliot](https://pdfjs.community/u/elliot)\
**Post date:** [September 29, 2022, 9:19pm UTC](https://pdfjs.community/t/uncaught-typeerror-object-is-not-iterable-when-loading-annotation/2071/5 "2022-09-29T21:19:44Z")

</div>

Hi @tgordon ,

Thanks for getting back to me.

Even though I’m definitely on 8.7:

 ![Screen Shot 2022-09-29 at 5.16.39 PM](https://canada1.discourse-cdn.com/flex031/uploads/pdfjscommunity/original/2X/9/9f94a2d0c1cff9f3d1f89accae1f650897eaab60.png)

The code you sent doesn’t work for me, the annotations don’t load, and it fails when I try to set authorId - saying annotation is undefined.

If I add the await statements to my original code, it does get ride of the “object is not iterable” message, but then I get this message:

 ![Screen Shot 2022-09-29 at 5.18.48 PM](https://canada1.discourse-cdn.com/flex031/uploads/pdfjscommunity/original/2X/9/97dd34851a9894fd200b1c7aa1908277131260cf.png)

I should say, I’m loading a custom config, I’m not sure if that makes a difference.

---

<div class="post-metadata">

**Author:** ![tgordon](https://avatars.discourse-cdn.com/v4/letter/t/aca169/32.png) [@tgordon](https://pdfjs.community/u/tgordon)\
**Post date:** [October 5, 2022, 6:56pm UTC](https://pdfjs.community/t/uncaught-typeerror-object-is-not-iterable-when-loading-annotation/2071/6 "2022-10-05T18:56:07Z")

</div>

Hi Elliot,

fireEvent is not an available API, however `trigger` is which would be used like

```javascript
instance.Core.annotationManager.trigger('updateAnnotationPermission');

```

The await is necessary as the `importAnnotations` function is async

Best regards,  
Tyler Gordon  
Web Development Support Engineer  
PDFTron

Share how you are using PDF.js Express in your organization you could win a **$500 Amazon gift card. All participants will receive 6 months of PDF.js Express+ for free**. Learn more [here](https://utm.guru/ueQNw)
