Skip to content

PDF Generation Template Editor

Open-source visual PDF generation engine with customizable templates and developer-friendly APIs.

View on GitHub

Stamps ​

Stamps are image-based annotations dropped onto the page. The WebViewer supports standard, dynamic, and custom stamps, managed through the stamp panel rubberStampPanel and a set of UI APIs.

UI APIs ​

UI.setStampPanelTabs(tabs) ​

Configure the tabs shown in the stamp panel.

javascript
UI.setStampPanelTabs([
  { type: 'tab', dataElement: 'STANDARD' },
  { type: 'tab', dataElement: 'DYNAMIC' },
  { type: 'tab', dataElement: 'CUSTOM' },
]);

Each tab is { type, dataElement, text? }. type: 'tab' is a built-in tab (STANDARD, DYNAMIC, CUSTOM); type: 'custom' is an import tab that shows the images set with setImportStamps; text is the tab title.

UI.setImportStamps(images) ​

Set the images shown in the import tab.

javascript
UI.setImportStamps(['data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg==']);

UI.addCustomStamps(images) ​

Add custom stamp images (PNG data URLs) to the front of the custom stamps.

javascript
UI.addCustomStamps(['data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg==']);

Custom stamps are saved for the instance and restored next time.

UI.setCustomStamps(images) ​

Replace the custom stamps.

javascript
UI.setCustomStamps([]);

UI.getCustomStamps() ​

Get the current custom stamps.

javascript
/**
 * @method UI.getCustomStamps
 * @returns {string[]} Image data URLs.
 */
const stamps = UI.getCustomStamps();

Stamp state ​

StatePurpose
Stamp panel tabsSet with setStampPanelTabs.
Import stampsSet with setImportStamps.
Custom stampsSet with addCustomStamps / setCustomStamps; saved for the instance.

Stamp components ​

  • Stamp panel (rubberStampPanel) — the standard, dynamic and custom stamps. It opens from rubberStampPanelToggle in the annotation tools.
  • Custom stamp dialog (customStampModal) — create a text stamp or an image stamp.

Core (stamp surface) ​

APIPurpose
new Annotations.StampAnnotation()Create a stamp in code; setStampText(text, { date, color, shape }) or setImageData(dataUrl).
documentViewer.getTool(Tools.ToolNames.RUBBER_STAMP)The stamp tool; place a stamp interactively.

See Create Annotations.

Examples ​

Add a custom stamp and open the stamp panel ​

javascript
UI.addCustomStamps(['data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg==']);
UI.setToolbarGroup('toolbarGroup-Annotate');
UI.openElement('rubberStampPanel');

Restrict the stamp panel to standard + custom ​

javascript
UI.setStampPanelTabs([
  { type: 'tab', dataElement: 'STANDARD' },
  { type: 'tab', dataElement: 'CUSTOM' },
]);

Select the custom tab ​

javascript
UI.setSelectedTab('rubberStampTab', 'customStampPanelButton');

The tab can be standardStampPanelButton, dynamicStampPanelButton, customStampPanelButton, the dataElement of a tab (STANDARD, DYNAMIC, CUSTOM), or the dataElement of a custom tab added with setStampPanelTabs, such as IMPORT. The panel opens on the selected tab.

Read current custom stamps ​

javascript
console.log(UI.getCustomStamps().length);