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.
Almost every visible part of the UI is an element identified by a data-element string. This guide covers the APIs that open/close, enable/disable, and tab between elements.
The UI state keeps two maps keyed by data-element: which elements are open, and which elements are disabled. Tab panels also keep their active tab.
UI.openElement(dataElement) // Open one element
UI.openElements(dataElements) // Open several: string[]
UI.closeElements(dataElements) // Close one or several: string | string[]
UI.toggleElementVisibility(dataElement) // Open if closed, close if open
UI.isElementOpen(dataElement) // => booleanOpening a panel closes the other panel on the same side (left/right), so only one panel per side is open at a time. UI.Events.VISIBILITY_CHANGED fires with (dataElement, isVisible).
/**
* @method UI.disableElements
* @param {string[] | string} dataElements One data-element or an array.
*/
UI.disableElements(['printButton', 'downloadButton']);
/**
* @method UI.enableElements
* @param {string[] | string} dataElements One data-element or an array.
*/
UI.enableElements(['printButton']);
UI.isElementDisabled('downloadButton'); // => truedisableElements removes the element from the UI. It does not disable the underlying feature. For example, disabling printButton removes the button, but printing can still be started with UI.print() or the keyboard shortcut. To turn off a feature, use UI.disableFeatures([UI.Feature.Print]), or the Core permission APIs.
In the notes panel, noteState is the review status button and noteMark is the mark check box of each annotation card:
UI.disableElements(['noteState', 'noteMark']);UI.updateElement(dataElement, overrides) overrides properties of a button wherever it appears (header, flyout, popup), such as label, title, img, disabled or onClick.
UI.updateElement('printButton', { title: 'Print this document' });UI.setActiveTabInPanel({ tabPanel: 'tabPanel', tabName: 'notesPanel' });Sets the active tab inside a tab panel. The tabs of the left panel tabPanel are thumbnailsPanel, outlinesPanel, notesPanel, layersPanel, signaturePanel and searchPanel.
tabPanel, thumbnailsPanel, outlinesPanel, notesPanel, layersPanel, signaturePanel, searchPanel, stylePanel, pageModePanel, formFieldPanel, rubberStampPanel, linkPanel, textEditingPanel, colorSeparationPanel, redactionStylePanel.
leftPanelButton, fullscreenButton, panToolButton, zoom-container, snippingToolButton, searchPanelToggle, menuButton, and the main menu items filePickerButton, viewSettingsButton, downloadButton, flattenDownloadButton, printButton, lightThemeButton, darkThemeButton, settingsButton.
toolbarGroup-View, toolbarGroup-Annotate, toolbarGroup-Forms, toolbarGroup-Measure, toolbarGroup-FillAndSign, toolbarGroup-Security, toolbarGroup-Redact, toolbarGroup-Compare, toolbarGroup-EditText, toolbarGroup-Document, toolbarGroup-Separation.
stylePanelToggle, formFieldPanelToggle.
default-top-header, tools-header, page-nav-floating-header.
settingsModal, passwordModal, signatureModal, securityModal, insertPageModal, compareSettingModal, warningModal, errorModal, and more.
Use the browser DOM inspector to find the
data-elementof any element on screen.
UI.closeElements(['tabPanel']);
UI.disableElements(['printButton', 'downloadButton', 'flattenDownloadButton']);UI.setToolbarGroup('toolbarGroup-Annotate');
UI.openElement('stylePanel');addCustomModal Custom modals are controlled with the same element APIs using their dataElement:
UI.addCustomModal({ dataElement: 'myModal', body: { title: 'Hello' } });
UI.openElement('myModal');
// later
UI.closeElements(['myModal']);
// or remove it entirely
UI.disableElements(['myModal']);disabledElements (an option of ComPDFKitViewer()) are disabled before the UI is first rendered.