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.
Popups are small floating menus. Each popup is an object on instance.UI with the same interface.
| Method | Description |
|---|---|
getItems() | Returns a copy of the items. Each item has a dataElement. |
add(items, dataElement?) | Insert one item or an array of items after the item dataElement; without it (or when it is not found) the items are inserted at the beginning. Returns the popup. |
update(items) | Replace all items. Returns the popup. |
Built-in items only need their dataElement. Custom items need a type and a dataElement:
type | Item |
|---|---|
customButton | A button with img, label, title and onClick. |
statefulButton | A button with several states (see Header & Toolbar). |
toggleButton | A button that opens/closes toggleElement. |
toolButton | A button that activates toolName. |
divider | A separator. |
UI.textPopup Appears after text is selected.
Default items: copyTextButton, textHighlightToolButton, textUnderlineToolButton, textStrikeoutToolButton, textSquigglyToolButton.
UI.annotationPopup Appears after an annotation is selected.
Default items: annotationReplyButton, annotationCopyButton, measureSettingsButton, annotationStyleEditButton, annotationDeleteButton. Items that do not apply to the selected annotation are not shown.
UI.contentEditPopup Appears after a content block is selected in content editing.
Default items: contentEditCopyButton, contentEditPropertyButton, contentEditDeleteButton.
UI.snippingToolPopup Appears after an area is selected with the snipping tool.
Default items: snippingDownloadButton, snippingExitButton.
UI.contextMenuPopup The right-click menu. It has no default items and is not shown by the default UI; its items can still be read and written.
A popup is placed next to its target (the selected text, annotation, content block or area) and is moved inside the visible area of the document. It closes when the selection is cleared.
UI.annotationPopup.add({
type: 'customButton',
dataElement: 'logAnnotationButton',
label: 'Log',
onClick: () => {
const [annotation] = instance.Core.annotationManager.getSelectedAnnotations();
console.log(annotation);
},
}, 'annotationCopyButton');UI.textPopup.update([
{ dataElement: 'copyTextButton' },
{ type: 'divider', dataElement: 'textPopupDivider' },
{
type: 'customButton',
dataElement: 'logTextButton',
label: 'Log',
onClick: () => console.log(instance.Core.documentViewer.getSelectedText()),
},
]);UI.annotationPopup.update(
UI.annotationPopup.getItems().filter(item => item.dataElement !== 'annotationCopyButton'),
);
// or hide it
UI.disableElements(['annotationCopyButton']);