Make Custom Stamps Standard

WebViewer Version: 8.1

I would like to add custom stamps that cannot be changed/edited/removed. I need to remove all standard stamps as well. Basically I want the exact behavior of standard stamps but using my custom stamps.

	const customStamps = [{
			title: "Approved",
			subtitle: "[By $currentUser at] h:mm:ss a, MMMM D, YYYY",
			opacity: .6,
			id: 'approved',
		},
		{
			title: "Not Approved",
			subtitle: "[By $currentUser at] h:mm:ss a, MMMM D, YYYY",
			color: new Annotations.Color('#D65656'),
			opacity: .6,
			id: 'not-approved'
		},
	];
	tool.setStandardStamps(customStamps);

something like that. I don’t want my users adding, deleting or modifying my stamps.

Hello benb, welcome to the Apryse community forum!

There is a difference between Standard and Custom stamps:

  • Standard Stamps are Stamp types that are defined by the PDF spec, a list can be found here: Apryse Documentation | Documentation
  • Custom Stamps are stamps that can be modified to have any look, as you are doing in your code snippet.

I think the solution here would be to disable the Standard Stamps and only use custom

WebViewer({
... constructor options ...
disabledElements: ['standardStampPanelButton', 'createCustomStampButton', 'deleteCustomStampButton'],
...
}, (instance) => {
      const { annotationManager, documentViewer, Tools, Annotations } = instance.Core;

      const stampTool = instance.Core.documentViewer.getTool(Tools.ToolNames.RUBBER_STAMP);
      stampTool.setStandardStamps([]);
      instance.UI.setSelectedTab('rubberStampTab', 'customStampPanelButton');
      const customStamps = [{
        title: "Approved",
        subtitle: "[By $currentUser at] h:mm:ss a, MMMM D, YYYY",
        opacity: .6,
        id: 'approved',
      },
      {
        title: "Not Approved",
        subtitle: "[By $currentUser at] h:mm:ss a, MMMM D, YYYY",
        color: new Annotations.Color('#D65656'),
        opacity: .6,
        id: 'not-approved'
      },
      ];
      stampTool.setCustomStamps(customStamps);


})

Let me know if this works for you,

Best regards,
Tyler

This is helpful…

I actually already had: setStandardStamps([]) in my code. It is the disableElements ('‘createCustomStampButton’,
‘deleteCustomStampButton’) that I need to get working.

I have added it to the constructor and after adding the setSelectedTab call and they still show. I don’t see dataElement deleteCustomStampButton in the code anywhere.

Hello benb,

Can you try this with our latest version v10.6?
I was able to get this working on this version.

Best regards,
Tyler

Will do. That raises another topic. Is there a CDN we can use to get the package? Or … this project is a PHP environment and composer keep things up to date, any chance there is support for that?

Works Perfectly. Thank you.