How can I create new RubberStampCreateTool and have another set of stamps in it?

WebViewer Version: 8.2.0
How can I create another new RubberStampCreateTool and have another set of stamps in it?

Hello, I’m Ron, an automated tech support bot :robot:

While you wait for one of our customer support representatives to get back to you, please check out some of these documentation pages:

Guides:APIs:Forums:

Hi @nuttakit,

With the following code snippet you can create a new instance of the RubberStamp tool and add it to the UI. You can then set the standard and custom stamps for it. Currently in the UI we only support displaying the stamps from the default tool in the dropdown overlay for choosing stamps.

However, if you are selecting the stamps for your new tool from somewhere else then this code should help you.

  const { documentViewer, Tools, annotationManager} = instance.Core;
  const CustomRubberStampCreateTool = new Tools.RubberStampCreateTool(documentViewer);
  const standardStamps = CustomRubberStampCreateTool.getStandardStamps();
 // For example, this new tool will only have two standard stamps
  const myStamps = [standardStamps[0], standardStamps[1]];
  CustomRubberStampCreateTool.setStandardStamps(myStamps)

  instance.UI.registerTool({
    toolName: 'CustomRubberStampCreateTool',
    toolObject: CustomRubberStampCreateTool,
    buttonImage: 'icon-tool-stamp-line',
    buttonName: 'CustomRubberStampToolButton',
    tooltip: 'CustomRubberStamp'
  });

  instance.UI.setHeaderItems(function(header) {
    header.getHeader('toolbarGroup-Annotate').push({
      type: 'toolGroupButton',
      toolGroup: 'rubberStampTools',
      dataElement: 'customRubberStampTools',
      title: 'Custom Stamp',
    });
  });

Some relevant APIs:
setStandardStamps
setCustomStamps

Best Regards,

Armando Bollain
Software Developer
PDFTron Systems, Inc.
www.pdftron.com

Hi Armando, thank you for you time
however, I test your code.

only this is need

instance.UI.setHeaderItems(function(header) {
    header.getHeader('toolbarGroup-Annotate').push({
      type: 'toolGroupButton',
      toolGroup: 'rubberStampTools',
      dataElement: 'customRubberStampTools',
      title: 'Custom Stamp',
    });
  });

but it just copy the instant of the rubberStampCreateTools (the button get push together, the stamp inside are the same) not a new instant of rubber stamp with new set of stamps

Hi @nuttakit,

I reviewed the source code in detail, and found that unfortunately we do not currently support having two separate RubberStamp tools at once in the UI. Currently we have hardcoded the name of the default rubber stamp, which is why even though the code I shared adds a second instance of the tool, the UI only ever uses one. I can add this as a feature request to our backlog, but can’t give you an exact estimate on when it will be completed or worked on.

That being said, you can still add a second tool, but you would have to write some custom UI on your app to use it and select the stamps.

Perhaps another alternative for you is to change what stamps are available based on specific actions? That way you can still show two distinct sets of stamps, while using the same tool.

Best Regards,

Armando Bollain
Software Developer
PDFTron Systems, Inc.
www.pdftron.com