How to customize the annotation content

PDF.js Express Version

7.1.0
Detailed description of issue
Hi!
How to customize the annotations and comments this way: initially we display it as a div with the author, date and the text annotated, but we need to replace the author’s name with some other dynamic value. Is the customization way applicable to pdftron?
Thanks!

Expected behaviour
image

Link to document
any

Code snippet

Hi! Thanks for trying out Express.

You can set the author of an annotation dynamically with the setAnnotationDisplayAuthorMap API.

You can also set the current user using the setCurrentUser API.

To change the default name for users you can set the annotationUser property in the constructor options.

I hope this helps! Let me know if there are any more questions.

Thanks,
Logan

1 Like

I’m having trouble setting the user, always returning to me Guest, when I create a new comment

WebViewer({
      path: '../lib',
      initialDoc: '../files/planta-baixa.pdf',
    }, this.viewer.nativeElement).then(instance => {

      const {annotManager, docViewer, Tools} = instance;

      annotManager.setCurrentUser('10010');

      annotManager.setAnnotationDisplayAuthorMap((annotation) => {
        if (annotation.Id === '10010') {
          return 'Alberto Carneiro';
        } else {
          return 'Convidado: ' + annotation.Id;
        }
      });

image

correction
change annotation.Id to annotation.Author

1 Like