Some test text!

Loading...
Guides
Display authors

Customize display authors for annotations

Often, users will want to change the user name they use for creating annotations. This can create an issue for existing annotations, as these will be linked to a particular annotationUser identifier. The way to get around this is to use display authors, that way the userId attached to an annotation can remain the same, while the display author changes to whatever the user wants it to be.

In the following example we will show how to map a userId (a unique identifier that won't change after being assigned), to a display name.

Map a userId to a Display Author

Add a mapping function with setAnnotationDisplayAuthorMap to map the userId to a display author, which will be used as the annotation author name in WebViewer.

For 7.x and below the mapping function takes in an annotation instead of a userId. Use setCustomData and getCustomData to save a userId to an annotation when it is created. Then add a mapping function with setAnnotationDisplayAuthorMap to map the userId to a display author, which will be used as the annotation author name in WebViewer.

WebViewer({
  annotationUser: '1',
  // other constructor options
}, viewerElement).then(instance => {
  const { annotationManager } = instance.Core;

annotManager.setAnnotationDisplayAuthorMap((userId) => {
  if (userId === '1') {
    return 'Will Ricker';
  } else if (userId === '2') {
    return 'Jean-Luc Picard'
  } else {
    return 'Guest';
  }
});

  annotationManager.setAnnotationDisplayAuthorMap(mapNames);

  // Now you can get a display author by passing in a unique ID
  const displayAuthor = annotationManager.getDisplayAuthor(annotation.Author);
});

You can also set whether to use the display name as the author name in the XFDF whenever exporting the annotations, by passing the option useDisplayAuthor: true to exportAnnotations

Get the answers you need: Support