Custom Redact button with Rectangle annotation

Hi there,

PDF.js Express does not support redaction unfortunately (if you want redaction you should take a look at our sister product).

If you wanted to fake it, there was a similar issue here you can reference, but you would use a RectangleCreateTool instead.

To remove the options to change the color etc, you can use the disableElements API to remove the elements you want when the annotation is selected.

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

   instance.on('annotationSelected', ([annot]) => {
      if(annot instanceof Annotations.RectangleAnnotation) {
          instance.disableElements(['annotationStyleEditButton']);
      } else {
          instance.enableElements(['annotationStyleEditButton']);
       }
   })
})

Something like this should help.

Thanks!
Logan