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.
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.addPanel(panel) Add a panel to the panel list.
/**
* @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.
const panels = UI.getPanels();
UI.setPanels(panels.filter(panel => panel.dataElement !== 'myPanel'));UI.getPanels() Returns the panel objects of the current UI.
const panels = UI.getPanels();
console.log(panels.map(panel => `${panel.dataElement}:${panel.location}`));| Member | Description |
|---|---|
dataElement | Name of the panel. |
location | 'left' or 'right'; assigning it moves the panel. |
render | The 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.
| API | Purpose |
|---|---|
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. |
| Panel | Location | Contents |
|---|---|---|
tabPanel | left | Tab panel with the tabs below. |
stylePanel | right | Annotation style properties. |
pageModePanel | right | View settings (layout, page mode). |
formFieldPanel | right | Form field properties. |
rubberStampPanel | right | Stamps. |
linkPanel | right | Link properties. |
textEditingPanel | right | Content editing properties. |
colorSeparationPanel | right | Color separation. |
redactionStylePanel | right | Redaction style. |
UI.Panels lists the panel names as constants.
| Tab | Contents |
|---|---|
thumbnailsPanel | Page thumbnails. |
outlinesPanel | Document outline. |
notesPanel | Annotation list. |
layersPanel | Layers. |
signaturePanel | Signatures. |
searchPanel | Text search. |
UI.openElement('tabPanel');
UI.setActiveTabInPanel({ tabPanel: 'tabPanel', tabName: 'outlinesPanel' });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.
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.
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');const panel = UI.getPanels().find(panel => panel.dataElement === 'pageModePanel');
panel.setLocation('left');const panel = UI.getPanels().find(panel => panel.dataElement === 'customPanel');
panel.delete();const tabPanel = UI.getPanels().find(panel => panel.dataElement === 'tabPanel');
tabPanel.panelsList = tabPanel.panelsList.filter(tab => tab.render !== 'layersPanel');