Skip to content

PDF Generation Template Editor

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

View on GitHub

Show / Hide Elements ​

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 APIs ​

Open / close ​

javascript
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)            // => boolean

Opening 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).

Enable / disable ​

javascript
/**
 * @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'); // => true

disableElements 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:

javascript
UI.disableElements(['noteState', 'noteMark']);

Update an element ​

UI.updateElement(dataElement, overrides) overrides properties of a button wherever it appears (header, flyout, popup), such as label, title, img, disabled or onClick.

javascript
UI.updateElement('printButton', { title: 'Print this document' });

Active tab ​

javascript
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.

Common data-elements ​

Panels ​

tabPanel, thumbnailsPanel, outlinesPanel, notesPanel, layersPanel, signaturePanel, searchPanel, stylePanel, pageModePanel, formFieldPanel, rubberStampPanel, linkPanel, textEditingPanel, colorSeparationPanel, redactionStylePanel.

Toolbar / header buttons ​

leftPanelButton, fullscreenButton, panToolButton, zoom-container, snippingToolButton, searchPanelToggle, menuButton, and the main menu items filePickerButton, viewSettingsButton, downloadButton, flattenDownloadButton, printButton, lightThemeButton, darkThemeButton, settingsButton.

Toolbar groups ​

toolbarGroup-View, toolbarGroup-Annotate, toolbarGroup-Forms, toolbarGroup-Measure, toolbarGroup-FillAndSign, toolbarGroup-Security, toolbarGroup-Redact, toolbarGroup-Compare, toolbarGroup-EditText, toolbarGroup-Document, toolbarGroup-Separation.

Property-panel buttons ​

stylePanelToggle, formFieldPanelToggle.

Layout ​

default-top-header, tools-header, page-nav-floating-header.

Dialogs ​

settingsModal, passwordModal, signatureModal, securityModal, insertPageModal, compareSettingModal, warningModal, errorModal, and more.

Use the browser DOM inspector to find the data-element of any element on screen.

Examples ​

Start with the left panel closed and a clean toolbar ​

javascript
UI.closeElements(['tabPanel']);
UI.disableElements(['printButton', 'downloadButton', 'flattenDownloadButton']);

Open the style panel ​

javascript
UI.setToolbarGroup('toolbarGroup-Annotate');
UI.openElement('stylePanel');

Toggle a custom modal registered with addCustomModal ​

Custom modals are controlled with the same element APIs using their dataElement:

javascript
UI.addCustomModal({ dataElement: 'myModal', body: { title: 'Hello' } });
UI.openElement('myModal');
// later
UI.closeElements(['myModal']);
// or remove it entirely
UI.disableElements(['myModal']);

Internal behavior notes ​

  • Elements disabled with disabledElements (an option of ComPDFKitViewer()) are disabled before the UI is first rendered.
  • Enabling and disabling have priorities: an element disabled by the integrator stays disabled even when the UI would show it (for example in view-only mode).
  • Measurement and color separation cannot be opened on mobile devices; the UI shows a "not supported" dialog instead.