# How to get the annotation id when I highlight some text and also how to get the page no, quads and highlighted text from my annotations object?

**URL:** <https://pdfjs.community/t/how-to-get-the-annotation-id-when-i-highlight-some-text-and-also-how-to-get-the-page-no-quads-and-highlighted-text-from-my-annotations-object/977>\
**Category:** Technical Support\
**Created:** [September 8, 2021, 6:55am UTC](https://pdfjs.community/t/how-to-get-the-annotation-id-when-i-highlight-some-text-and-also-how-to-get-the-page-no-quads-and-highlighted-text-from-my-annotations-object/977 "2021-09-08T06:55:27Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![arman](https://avatars.discourse-cdn.com/v4/letter/a/258eb7/32.png) [@arman](https://pdfjs.community/u/arman)\
**Post date:** [September 8, 2021, 6:55am UTC](https://pdfjs.community/t/how-to-get-the-annotation-id-when-i-highlight-some-text-and-also-how-to-get-the-page-no-quads-and-highlighted-text-from-my-annotations-object/977/1 "2021-09-08T06:55:27Z")

</div>

**PDF.js Express Version**  
8.0.1

**Detailed description of issue**  
Previously in version 7.2.1, I write some code [code provided in code snippet section] to get the annotation id, quad, text, and page no but in version 8.0.1 I have not found annotations[0][‘Ku’], annotations[0].Ob, annotations[0].E\_, annotations[0].JF this attributes from annotations object.

**Expected behavior**  
When I highlight some text then it will highlight the text but now got this error, " Unhandled Rejection (TypeError): Cannot read properties of undefined (reading ‘toString’)"

**Does your issue happen with every document, or just one?**  
It happens for every document.

**Link to document**

1. [https://journals.plos.org/plosone/article/file?id=10.1371/journal.pone.0240011&type=printable](https://journals.plos.org/plosone/article/file?id=10.1371/journal.pone.0240011&type=printable)
2. [https://journals.plos.org/plosone/article/file?id=10.1371/journal.pone.0207335&type=printable](https://journals.plos.org/plosone/article/file?id=10.1371/journal.pone.0207335&type=printable)

**Code snippet**

```javascript
annotManager.on('annotationChanged', (annotations, action, { imported }) => {
  const citations = this.props.citations.filter(x => x.id == annotations[0]['Ku']);
  annotManager.exportAnnotCommand().then((xfdfString) => {
    var xfdfJson = JSON.parse(convert.xml2json(xfdfString, { compact: true, spaces: 4 }).toString());
    
    if (xfdfJson.xfdf.add['highlight'] !== undefined && xfdfJson.xfdf.add['text'] === undefined && annotations[0]['Subject'] === "Highlight" && citations.length === 0 && action === 'add') {
      const highlight = annotManager.getAnnotationById(annotations[0]['Ku'].toString());
      this.props.onTextSelectionChanged({
        quads: annotations[0].Ob,
        text: annotations[0].E_,
        page: annotations[0].JF,
      });
    }
  })
});

```

---

_[View the full topic](https://pdfjs.community/t/how-to-get-the-annotation-id-when-i-highlight-some-text-and-also-how-to-get-the-page-no-quads-and-highlighted-text-from-my-annotations-object/977)._
