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<Annotation[]>
.
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.
- 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.
- 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.
- 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; }>
.