Working with Annotations
Annotations can be read from, and written to, a MuPDF document instance. In this way a developer is able to separately store annotations and programmatically manage them.Annotation data format
Annotations are read and written to the MuPDF WebViewer in a JSON format, referenced asAnnotation[] the format is as follows:
Reading annotation data
To read annotation data from a document we use the annotation.get() method. Once we have the data we can work with it just as we would with any JSON object. ExampleWriting annotation data
To write annotation data to a document we use the annotation.add() method. For example, to write annotations to the document from JSON data stored in local storage we could do the following: ExampleRemoving annotation data
Annotations can be removed from a document by using the annotation.remove() method. To remove an annotation, provide either itsoid (unique across the document) or its name and pageIndex (since name is only unique within a page).
Example
Setting the Annotation Author
When creating annotations in MuPDF WebViewer you can predefine the author of the annotation by listening to theANNOTATION_CREATE event and then setting the annotation metadata for the author name.
Example