PDF Generation Template Editor
Open-source visual PDF generation engine with customizable templates and developer-friendly APIs.
Open-source visual PDF generation engine with customizable templates and developer-friendly APIs.
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.setStampPanelTabs(tabs) Configure the tabs shown in the stamp panel.
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.
UI.setImportStamps(['data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg==']);UI.addCustomStamps(images) Add custom stamp images (PNG data URLs) to the front of the custom stamps.
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.
UI.setCustomStamps([]);UI.getCustomStamps() Get the current custom stamps.
/**
* @method UI.getCustomStamps
* @returns {string[]} Image data URLs.
*/
const stamps = UI.getCustomStamps();| State | Purpose |
|---|---|
| Stamp panel tabs | Set with setStampPanelTabs. |
| Import stamps | Set with setImportStamps. |
| Custom stamps | Set with addCustomStamps / setCustomStamps; saved for the instance. |
rubberStampPanel) — the standard, dynamic and custom stamps. It opens from rubberStampPanelToggle in the annotation tools.customStampModal) — create a text stamp or an image stamp.| API | Purpose |
|---|---|
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.
UI.addCustomStamps(['data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg==']);
UI.setToolbarGroup('toolbarGroup-Annotate');
UI.openElement('rubberStampPanel');UI.setStampPanelTabs([
{ type: 'tab', dataElement: 'STANDARD' },
{ type: 'tab', dataElement: 'CUSTOM' },
]);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.
console.log(UI.getCustomStamps().length);