ngx-extended-pdf-viewer icon indicating copy to clipboard operation
ngx-extended-pdf-viewer copied to clipboard

Modify annotation editor properties programmatically

Open stephanrauh opened this issue 1 year ago • 0 comments

Let's add a method allowing developers to modify the annotation editor parameters programmatically. The bare-bones approach looks like so:

const editorType = 11;
const fontSize = 42;
PDFViewerApplication.eventBus.dispatch('switchannotationeditorparams', {type: editorType, value:fontSize})
PDFViewerApplication.eventBus.dispatch('annotationeditorparamschanged', {details: [[editorType, fontSize]]});

Note the double brackets in the second line. It's an array of arrays, so you can modify multiple parameters at once.

These are the editor parameter types you can use:

const AnnotationEditorParamsType = {
  RESIZE: 1,
  CREATE: 2,
  FREETEXT_SIZE: 11,
  FREETEXT_COLOR: 12,
  FREETEXT_OPACITY: 13,
  INK_COLOR: 21,
  INK_THICKNESS: 22,
  INK_OPACITY: 23,
  HIGHLIGHT_COLOR: 31,
  HIGHLIGHT_DEFAULT_COLOR: 32,
  HIGHLIGHT_THICKNESS: 33,
  HIGHLIGHT_FREE: 34,
  HIGHLIGHT_SHOW_ALL: 35,
};

stephanrauh avatar Mar 11 '24 21:03 stephanrauh