Skip to content

PDF Generation Template Editor

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

View on GitHub

Panels ​

Panels are dynamic components shown on the left or right side of the UI. This guide covers the panel APIs, the built-in panels, and how custom panels are rendered.

UI APIs ​

UI.addPanel(panel) ​

Add a panel to the panel list.

javascript
/**
 * @method UI.addPanel
 * @param {object} panel
 * @param {string} panel.dataElement      Unique name of the panel.
 * @param {string} panel.location         'left' | 'right'
 * @param {string | function} panel.render A built-in panel name, or a function that returns an HTMLElement.
 */
UI.addPanel({
  dataElement: 'myPanel',
  location: 'left',
  render: () => {
    const el = document.createElement('div');
    el.textContent = 'My panel';
    return el;
  },
});

To show a built-in panel in another place, use its name as render, for example render: 'pageModePanel'.

UI.setPanels(panelList) ​

Replace the whole panel list. The list can contain panel objects returned by getPanels() or plain objects with dataElement, location and render.

javascript
const panels = UI.getPanels();
UI.setPanels(panels.filter(panel => panel.dataElement !== 'myPanel'));

UI.getPanels() ​

Returns the panel objects of the current UI.

javascript
const panels = UI.getPanels();
console.log(panels.map(panel => `${panel.dataElement}:${panel.location}`));

Panel objects ​

MemberDescription
dataElementName of the panel.
location'left' or 'right'; assigning it moves the panel.
renderThe built-in panel name or the render function.
setLocation(location)Move the panel to 'left' or 'right'.
delete()Remove the panel from the list.
toObject()Plain data of the panel.

The left panel tabPanel is returned as a tab panel object; its panelsList property reads and replaces its tabs.

Other panel APIs ​

APIPurpose
UI.setActiveTabInPanel({ tabPanel, tabName })Switch the active tab of a tab panel.
UI.setActiveLeftPanel(panelName)Switch the active tab of the left panel.
UI.setSideWindowVisibility(visible)Open or close the left panel.
UI.setPanelWidth(dataElement, width)Set the width of a panel (at least 264 px). UI.Events.PANEL_RESIZED fires.

Built-in panels ​

PanelLocationContents
tabPanelleftTab panel with the tabs below.
stylePanelrightAnnotation style properties.
pageModePanelrightView settings (layout, page mode).
formFieldPanelrightForm field properties.
rubberStampPanelrightStamps.
linkPanelrightLink properties.
textEditingPanelrightContent editing properties.
colorSeparationPanelrightColor separation.
redactionStylePanelrightRedaction style.

UI.Panels lists the panel names as constants.

Left panel tabs ​

TabContents
thumbnailsPanelPage thumbnails.
outlinesPanelDocument outline.
notesPanelAnnotation list.
layersPanelLayers.
signaturePanelSignatures.
searchPanelText search.
javascript
UI.openElement('tabPanel');
UI.setActiveTabInPanel({ tabPanel: 'tabPanel', tabName: 'outlinesPanel' });

Right panels ​

Only one panel is open on each side. The right panels are opened by their toggle buttons, such as stylePanelToggle (annotation tools) and formFieldPanelToggle (form tools), or with UI.openElement.

How custom panels are rendered ​

Every panel is rendered in the same panel shell. For a custom panel the shell calls render() when the panel is opened and inserts the returned element. The element belongs to the UI document (inside the iframe), so create it with the document of your page and the browser moves it in, or build its content with innerHTML.

Examples ​

Add and open a custom left panel ​

javascript
UI.addPanel({
  dataElement: 'customPanel',
  location: 'left',
  render: () => {
    const div = document.createElement('div');
    div.innerHTML = '<h3>Custom panel</h3><p>Any content here.</p>';
    return div;
  },
});
UI.openElement('customPanel');

Move a panel to the other side ​

javascript
const panel = UI.getPanels().find(panel => panel.dataElement === 'pageModePanel');
panel.setLocation('left');

Remove a panel ​

javascript
const panel = UI.getPanels().find(panel => panel.dataElement === 'customPanel');
panel.delete();

Replace the tabs of the left panel ​

javascript
const tabPanel = UI.getPanels().find(panel => panel.dataElement === 'tabPanel');
tabPanel.panelsList = tabPanel.panelsList.filter(tab => tab.render !== 'layersPanel');