The annotation object is an instance accessible from the main MuPDFWebViewer instance as follows:
const annotation = mupdf.annotation;
This assumes you have returned your instance name as mupdf from the initMuPDFWebViewer() promise!

annotation

The annotation object has the following methods:

get

get(config?: { pageIndex: number }) Gets annotations. Returns array of annotations.
  • Arguments:
    • config(optional) The configuration object. If undefined returns all annotations for all pages.
Config object:
  • Arguments:
    • pageIndex(required) Page index.
  • Returns: Promise<Annotation[]>.
Example
mupdf.annotation.get({pageIndex:0});
The Annotation[] array object is an array of JSON objects representing each annotation - see the Working with Annotations guide.

set

set(config: { annotations: Annotation[], emitEvent?: boolean }) Updates annotations.
  • Arguments:
    • config(required) The configuration object.
Config object:
  • Arguments:
    • annotations(required) An array of annotation objects.
    • emitEvent - (optional) Whether to emit events
You need to set oid or name and pageIndex as the unique key for the each required annotation.The Annotation[] array object is an array of JSON objects representing each annotation - see the Working with Annotations guide.

add

add(config: { annotations: Annotation[]; emitEvent?: boolean }) Adds annotations. Returns array of added annotations.
  • Arguments:
    • config(required) The configuration object.
Config object:
  • Arguments:
    • annotations(required) An array of annotation objects.
    • emitEvent(optional) Whether to emit events.
  • Returns: Promise<Annotation[]>.
The Annotation[] array object is an array of JSON objects representing each annotation - see the Working with Annotations guide.

remove

remove(config: { annotations: Array<{ name: string, pageIndex: number } | { oid: number, pageIndex: number }>, emitEvent?: boolean }) Removes annotations.
  • Arguments:
    • config(required) The configuration object.
Config object:
  • Arguments:
    • annotations(required) Array of annotation information to remove.
    • emitEvent(optional) Whether to emit events.
  • Returns: Promise.
Example
mupdf.annotation.remove({annotations:[
                                      {name:"squiggle_1", pageIndex:0},
                                      {name:"rectangle_10", pageIndex:3},
                                      {oid:36245, pageIndex:5}
                                      ]
                        });

undo

undo() Undoes annotation operations and returns success status.
  • Returns: Promise<{ success: boolean; }>.
Example
mupdf.annotation.undo();

redo

redo() Redoes undone annotation operations and returns success status.
  • Returns: Promise<{ success: boolean; }>.
Example
mupdf.annotation.redo();