Instance API

Annotations and Selection

Create, update, delete, and select annotations with ViewerInstance APIs.

Annotation CRUD

  • create(annotation | annotation[])
  • update(annotation | annotation[])
  • delete(id | ids | annotations)
  • getAnnotations(pageIndex?)

Selection helpers

  • getSelection()
  • getTextSelection()
  • setSelectionMode(mode)
  • getSelectionMode()
  • setSelectedAnnotations(...)
  • getSelectedAnnotations()

Deletion patterns

  • API (compat): delete(id | ids | annotations)
  • API (core): deleteAnnotation(id) and deleteAnnotations(ids)
  • Chrome UI:
    • Press Delete or Backspace when annotations are selected.
    • Use the delete button in the annotations sidebar row.

Fast creation from text selection

  • createNoteFromSelection(contents?)
  • createLinkFromSelection(url)
  • createHighlightFromSelection()
  • createUnderlineFromSelection()

Mode and author

  • setAnnotationMode(mode)
  • getAnnotationMode()
  • setSelectionMode(mode)
  • getSelectionMode()
  • setAnnotationCreatorName(name)
  • getAnnotationCreatorName()

Selection modes

  • text (default): drag selects by text range endpoints, similar to standard text selection.
  • rectangle: drag creates a rectangular selection box and you can resize it from corner handles.
  • getSelection() returns the current selection rects for the active mode.

Chrome drawing settings bar

  • The floating drawing settings bar appears only while a drawing annotation mode is active:
    • ink, square, rectangle, circle, ellipse, line, polygon, polyline.
  • The same floating bar also appears when one or more editable selected annotations are all drawing types.
  • It controls preset values used for newly created annotations in that mode:
    • color
    • strokeWidth
    • borderStyle (solid or dashed)
  • When the bar is shown because drawing annotations are selected, the controls update the selected annotations directly.