# Custom Rubber Stamp

**URL:** <https://pdfjs.community/t/custom-rubber-stamp/110>\
**Category:** Technical Support\
**Created:** [July 3, 2020, 5:57am UTC](https://pdfjs.community/t/custom-rubber-stamp/110 "2020-07-03T05:57:52Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![abhishek11.maurya199](https://avatars.discourse-cdn.com/v4/letter/a/ed655f/32.png) [@abhishek11.maurya199](https://pdfjs.community/u/abhishek11.maurya199)\
**Post date:** [July 3, 2020, 5:57am UTC](https://pdfjs.community/t/custom-rubber-stamp/110/1 "2020-07-03T05:57:52Z")

</div>

This is just a question.  
Can be put custom rubber stamp after we purchase the license.  
For example i have to put stamp of 3 line:  
" Exhibit  
1235332  
03-07-20"  
If custom rubber stamp feature is not there then can we do it via calling some API  
or slight modification in code.

---

<div class="post-metadata">

**Author:** ![Logan](https://yyz1.discourse-cdn.com/flex031/user_avatar/pdfjs.community/logan/32/13_2.png) [@Logan](https://pdfjs.community/u/Logan)\
**Post date:** [July 6, 2020, 4:44pm UTC](https://pdfjs.community/t/custom-rubber-stamp/110/2 "2020-07-06T16:44:43Z")

</div>

Hey there,

Thanks for trying out PDF.js Express!

Custom rubber stamps can be created by creating a canvas, drawing whatever you want on it, calling toDataURL, then setting that as the ImageData for a stamp annotation.

Here is an example of what you might do:

```javascript
const stampAnnot = new Annotations.StampAnnotation();
stampAnnot.PageNumber = 1;
stampAnnot.X = 100;
stampAnnot.Y = 250;
stampAnnot.Width = 275;
stampAnnot.Height = 40;

// create a canvas in memory to draw your text to
const canvas = document.createElement('canvas');
const context = canvas.getContext('2d');

// Your own function to add text to a canvas using the HTML5 canvas API
drawTextToCanvas(context, 'Exhibit 1235332 03-07-20')

// convert your canvas to a data URL
const dataURL = canvas.toDataURL(); 

// put your data URL here
stampAnnot.ImageData = dataURL;

annotManager.addAnnotation(stampAnnot);
annotManager.redrawAnnotation(stampAnnot);

```

I hope this helps!

Logan

---

<div class="post-metadata">

**Author:** ![abhishek11.maurya199](https://avatars.discourse-cdn.com/v4/letter/a/ed655f/32.png) [@abhishek11.maurya199](https://pdfjs.community/u/abhishek11.maurya199)\
**Post date:** [July 7, 2020, 9:42am UTC](https://pdfjs.community/t/custom-rubber-stamp/110/3 "2020-07-07T09:42:38Z")

</div>

Thank you logan for the code, just have small doubt  
that the “Annotations” object is always showing “undefined” when  
I try to load it in “/samples/realtime-collaboration.js” after below line:  
const { docViewer, annotManager } = instance;

Could you please help me by mentioning where i can  
put the code snippet provided by you or how to remove this “undefined error”

Regards

---

<div class="post-metadata">

**Author:** ![Logan](https://yyz1.discourse-cdn.com/flex031/user_avatar/pdfjs.community/logan/32/13_2.png) [@Logan](https://pdfjs.community/u/Logan)\
**Post date:** [July 7, 2020, 2:31pm UTC](https://pdfjs.community/t/custom-rubber-stamp/110/4 "2020-07-07T14:31:07Z")

</div>

Hi,

The code I sent should be put inside the ‘documentLoaded’ event.

```javascript
WebViewer({...}).then(instance => {
   const { docViewer, annotManager, Annotations } = instance;

   docViewer.on('documentLoaded', () => {
      // the code I sent
   })
})

```

Hope this helps!

Thanks,  
Logan

---

<div class="post-metadata">

**Author:** ![tony](https://yyz1.discourse-cdn.com/flex031/user_avatar/pdfjs.community/tony/32/427_2.png) [@tony](https://pdfjs.community/u/tony)\
**Post date:** [June 25, 2021, 5:42am UTC](https://pdfjs.community/t/custom-rubber-stamp/110/5 "2021-06-25T05:42:33Z")

</div>

Hi Logan,

How i can disable the custom rubber stamp tab ?

Thanks

---

<div class="post-metadata">

**Author:** ![Logan](https://yyz1.discourse-cdn.com/flex031/user_avatar/pdfjs.community/logan/32/13_2.png) [@Logan](https://pdfjs.community/u/Logan)\
**Post date:** [June 25, 2021, 3:17pm UTC](https://pdfjs.community/t/custom-rubber-stamp/110/6 "2021-06-25T15:17:43Z")

</div>

Hey Tony, I believe I answered this question in your other ticket. If not, please open a new ticket,

---

<div class="post-metadata">

**Author:** ![Logan](https://yyz1.discourse-cdn.com/flex031/user_avatar/pdfjs.community/logan/32/13_2.png) [@Logan](https://pdfjs.community/u/Logan)\
**Post date:** [June 25, 2021, 3:17pm UTC](https://pdfjs.community/t/custom-rubber-stamp/110/7 "2021-06-25T15:17:45Z")

</div>


