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

**URL:** <https://pdfjs.community/t/how-to-hide-annotation-toolbar-for-drawing-when-the-annotate-button-is-hidden/2375>\
**Category:** Technical Support\
**Created:** [February 15, 2023, 4:31pm UTC](https://pdfjs.community/t/how-to-hide-annotation-toolbar-for-drawing-when-the-annotate-button-is-hidden/2375 "2023-02-15T16:31:41Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![rakshitha\_r](https://avatars.discourse-cdn.com/v4/letter/r/82dd89/32.png) [@rakshitha\_r](https://pdfjs.community/u/rakshitha_r)\
**Post date:** [February 15, 2023, 4:31pm UTC](https://pdfjs.community/t/how-to-hide-annotation-toolbar-for-drawing-when-the-annotate-button-is-hidden/2375/1 "2023-02-15T16:31:41Z")

</div>

**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}

```javascript
        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');
        });

```

---

<div class="post-metadata">

**Author:** ![zserviss](https://avatars.discourse-cdn.com/v4/letter/z/a9a28c/32.png) [@zserviss](https://pdfjs.community/u/zserviss)\
**Post date:** [February 15, 2023, 5:52pm UTC](https://pdfjs.community/t/how-to-hide-annotation-toolbar-for-drawing-when-the-annotate-button-is-hidden/2375/2 "2023-02-15T17:52:01Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![rakshitha\_r](https://avatars.discourse-cdn.com/v4/letter/r/82dd89/32.png) [@rakshitha\_r](https://pdfjs.community/u/rakshitha_r)\
**Post date:** [February 15, 2023, 7:30pm UTC](https://pdfjs.community/t/how-to-hide-annotation-toolbar-for-drawing-when-the-annotate-button-is-hidden/2375/3 "2023-02-15T19:30:56Z")

</div>

Yes Zserviss exactly it is my issue

---

<div class="post-metadata">

**Author:** ![zserviss](https://avatars.discourse-cdn.com/v4/letter/z/a9a28c/32.png) [@zserviss](https://pdfjs.community/u/zserviss)\
**Post date:** [February 15, 2023, 8:45pm UTC](https://pdfjs.community/t/how-to-hide-annotation-toolbar-for-drawing-when-the-annotate-button-is-hidden/2375/4 "2023-02-15T20:45:45Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![rakshitha\_r](https://avatars.discourse-cdn.com/v4/letter/r/82dd89/32.png) [@rakshitha\_r](https://pdfjs.community/u/rakshitha_r)\
**Post date:** [February 22, 2023, 3:15am UTC](https://pdfjs.community/t/how-to-hide-annotation-toolbar-for-drawing-when-the-annotate-button-is-hidden/2375/5 "2023-02-22T03:15:59Z")

</div>

thanks zserviss, this helped me

---

<div class="post-metadata">

**Author:** ![rakshitha\_r](https://avatars.discourse-cdn.com/v4/letter/r/82dd89/32.png) [@rakshitha\_r](https://pdfjs.community/u/rakshitha_r)\
**Post date:** [February 22, 2023, 3:18am UTC](https://pdfjs.community/t/how-to-hide-annotation-toolbar-for-drawing-when-the-annotate-button-is-hidden/2375/6 "2023-02-22T03:18:03Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![zserviss](https://avatars.discourse-cdn.com/v4/letter/z/a9a28c/32.png) [@zserviss](https://pdfjs.community/u/zserviss)\
**Post date:** [February 22, 2023, 3:47pm UTC](https://pdfjs.community/t/how-to-hide-annotation-toolbar-for-drawing-when-the-annotate-button-is-hidden/2375/7 "2023-02-22T15:47:08Z")

</div>

Hi @rakshitha_r

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

Best Regards,  
Zach Serviss  
Platform Support Engineer

---

<div class="post-metadata">

**Author:** ![rakshitha\_r](https://avatars.discourse-cdn.com/v4/letter/r/82dd89/32.png) [@rakshitha\_r](https://pdfjs.community/u/rakshitha_r)\
**Post date:** [February 22, 2023, 3:56pm UTC](https://pdfjs.community/t/how-to-hide-annotation-toolbar-for-drawing-when-the-annotate-button-is-hidden/2375/8 "2023-02-22T15:56:35Z")

</div>

hi @zserviss ,  
please see below link  
Added Question here

> [@AnnotationChanged event triggers as soon as pdf is opened with linkAnnotationEvent](https://pdfjs.community/t/annotationchanged-event-triggers-as-soon-as-pdf-is-opened/2387):
>
> Which product are you using? PDF.js Express Plus PDF.js Express Version 8 Detailed description of issue when i open the PDF, even though there is no annotation drawn, i am able to see annotation event getting triggered and it gives the action as add when i console Expected behaviour If there is any change with respect to annotation like export/import/ drawing a new annotation then only annotation changed event has to trigger. Does your issue happen with every document, or just one? al…
