# Do annotations from setCustomDrawHandler make it to the downloadable file?

**URL:** https://pdfjs.community/t/do-annotations-from-setcustomdrawhandler-make-it-to-the-downloadable-file/927
**Category:** Technical Support
**Created:** [August 3, 2021, 5:31pm UTC](https://pdfjs.community/t/do-annotations-from-setcustomdrawhandler-make-it-to-the-downloadable-file/927 "2021-08-03T17:31:03Z")
**Posts on this page:** 1
**Showing post:** 3

<div class="post-metadata">

### Author: ![Logan](https://yyz1.discourse-cdn.com/flex031/user_avatar/pdfjs.community/logan/32/13_2.png) [@Logan](https://pdfjs.community/u/Logan)
#### Post date: [August 4, 2021, 3:47pm UTC](https://pdfjs.community/t/do-annotations-from-setcustomdrawhandler-make-it-to-the-downloadable-file/927/3 "2021-08-04T15:47:34Z")

</div>

Hey there!

By default, annotations are only serialized with information that is in the PDF Spec, however we do have a mechanism to serialize custom data.

You can use the [setCustomData](https://pdfjs.express/api/Annotations.Annotation.html#setCustomData__anchor) API to set custom, serializable data on the annotation which can then be exported and reloaded.

You can call this function anywhere, including inside your draw handler:

```javascript
  Annotations.setCustomDrawHandler(
    Annotations.EllipseAnnotation,
    function (
      ctx, //canvas context
      pageMatrix,
      rotation,
      options
    ) {
      const annot = options.annotation;
      annot.setCustomData('index', 1); // Set the index/number here
      // ...rest
    }
  );

```

Now when you export XFDF, that custom data will be saved in it.

Next time you import that XFDF, you can access your custom data with [getCustomData](https://pdfjs.express/api/Annotations.Annotation.html#getCustomData__anchor).

Thanks!  
Logan

---

_[View the full topic](https://pdfjs.community/t/do-annotations-from-setcustomdrawhandler-make-it-to-the-downloadable-file/927)._
