Do annotations from setCustomDrawHandler make it to the downloadable file?

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 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:

  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.

Thanks!
Logan