How to hide annotation toolbar for drawing when the annotate button is hidden

Which product are you using?

PDF.js Express Plus
PDF.js Express Version

8
Detailed description of issue
I am able to hide annotation button even though annotate button is clicked, when we are importing xfdf data back to pdf. but i am not able to disable the annotate toolbar, i have coded like this,

Expected behaviour
when the annotate button is hidden, i should not be able to even draw annotation box in the pdf
Does your issue happen with every document, or just one?
{Answer here}
yes
Link to document
{Provide a link to the document in question if possible}

Code snippet
{Provide a relevant code snippet}

        this.setAnnotationEvent.subscribe(() => {
          //instance.UI.setToolbarGroup('toolbarGroup-Insert');
          const annotationsList = annotationManager.getAnnotationsList();
          const xfdfString = this.renderingInstance;
          annotationManager.importAnnotations(xfdfString);
          this.renderingInstance = '';
          let isChecked: any = [...this.annotationList.filter((ele: any) => ele.checked)];
          if (isChecked.length > 0) {
            if (instance.UI.getToolMode().name === 'AnnotationCreateRectangle') {
              instance.UI.disableElements(['annotationStyleEditButton']);
            }
            instance.UI.disableElements(['ribbons']);
            instance.UI.disableElements(['toolbarGroup-Annotate']);
            instance.UI.disableElements(['annotationStyleEditButton']);
          } else {
            instance.UI.enableElements(['ribbons']);
            instance.UI.enableElements(['toolbarGroup-Annotate']);
            instance.UI.enableElements(['annotationStyleEditButton']);
          }
          //instance.UI.setToolbarGroup('toolbarGroup-Insert');
        });

Hi @rakshitha_r,

Is the issue that the toolbar disappears, but it is still selected thus able to create annotations?

Best Regards,
Zach Serviss
Platform Support Engineer

Yes Zserviss exactly it is my issue

You can fix this by setting the tool back to the pan tool after disabling it with:

instance.UI.setToolMode('Pan')

This will simply just set the tool back to pan, making it unable to create an annotation.

Best Regards,
Zach Serviss
Platform Support Engineer

thanks zserviss, this helped me

zserviss, i have come across one wiered issue, i am able to save annotations and when i open the pdf, to draw annotation i was showing a popup to store comments customised popup, that is showing me the number of times i have created the annotation. for example, i have made 5 annotations and made save, when i open pdf, popup shows for 5 times. any help on this please

Hi @rakshitha_r

Could you please attach some screenshots/or a video explaining this issue?

Best Regards,
Zach Serviss
Platform Support Engineer

hi @zserviss ,
please see below link
Added Question here