Custom Rubber Stamp

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
If custom rubber stamp feature is not there then can we do it via calling some API
or slight modification in code.


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:

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;


I hope this helps!


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”



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

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

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

Hope this helps!


Hi Logan,

How i can disable the custom rubber stamp tab ?


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