Deserialize XFDF string into annotation without adding it to the viewer

Product: Webviewer

Product Version: 7

I know that it’s possible to import a XFDF annotation string by doing annotManager.importAnnotations(), but I have some custom data that I’d like to attach to the annotation before it’s added to the viewer. Is there a way for me to deserialize the string into an Annotation without actually adding it to the document?

Hi @martin.jones,

There is no API to create annotations from XFDF without adding them to the viewer. However, you could attach an event listener on the annotationChanged event on the AnnotationManager, and if the action is add and the imported flag is true from the AnnotationChangedInfoObject, then you can run your code to add custom data to the annotations.

There is also an API that allows you to have more granular control of how the annotations are added, by allowing you to transform the XFDF before it is imported. You can read more about it here:

Best Regards,
Armando Bollain
Software Developer
PDFTron Systems, Inc.
www.pdftron.com

Thanks for the reply @Armando_Bollain! That object you linked to is just what I need but didn’t realize existed on the event callback.

1 Like