annotation object is an instance accessible from the main MuPDFWebViewer instance as follows:
This assumes you have returned your instance name as
mupdf from the initMuPDFWebViewer() promise!annotation
Theannotation 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.
- Arguments:
- pageIndex – (required) Page index.
- Returns:
Promise<{ annotations: Annotation[] }>.
The
Annotation[] array contains annotation objects, also see the Working with Annotations guide.set
set(config: { annotations: Annotation[], emitEvent?: boolean })
Updates annotations.
- Arguments:
- config – (required) The configuration object.
- Arguments:
- annotations – (required) An array of annotation objects.
- emitEvent - (optional) Whether to emit events
The
Annotation[] array contains annotation objects, also 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.
- Arguments:
- annotations – (required) An array of annotation objects.
- emitEvent – (optional) Whether to emit events.
- Returns:
Promise<Annotation[]>.
The
Annotation[] array contains annotation objects, also 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.
- Arguments:
- annotations – (required) Array of annotation information to remove.
- emitEvent – (optional) Whether to emit events.
- Returns:
Promise.
undo
undo()
Undoes annotation operations and returns success status.
- Returns:
Promise<{ success: boolean; }>.
redo
redo()
Redoes undone annotation operations and returns success status.
- Returns:
Promise<{ success: boolean; }>.
Annotation Object
TheAnnotation object is a JSON object as follows:
oid(optional): Object idpageIndex(required): Page indexname(optional): Unique name in the pagerect(optional): Rectangle{ top: number, left: number, bottom: number, right: number }opacity(optional): Opacity (0.0 ~ 1.0)author(optional): AuthorcanBePrinted(optional): Whether to be printedlocked(optional): Whether to be lockedrotation(optional): Rotation in degreescreatedAt(optional): Creation date stringmodifiedAt(optional): Modification date stringcontents(optional): Contents stringfillColor(optional): Fill color string in hex format e.g.#RRGGBBposition(optional): Position{ x: number; y: number }popupNote(optional): Popup note object withrectproperty
oid or name then a new annotation will be created with auto assigned values.