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.
The WebViewer UI is a Vue 3 application. This page describes how it is mounted and how its main areas are built.
{uiPath}index.html (iframe; by default {path}webviewer/index.html)
└─ createUIInstance() src/instance/createUIInstance.ts
└─ createApp(RootComponent) src/instance/rootComponent.ts
└─ App src/components/App/
├─ modular headers (top / tools / bottom / left / right)
├─ panels (left / right)
├─ document container (pages, annotations, text selection)
├─ popups and overlays
└─ modals (built-in and custom)App App lays out the headers, the side panels and the document area, and hosts the popups, overlays and modals. It renders from the viewer store, so any change made through instance.UI is reflected immediately.
| Directory | Contents |
|---|---|
components/App/ | The application shell and layout. |
components/modular/ | Modular components: ModularHeader, ToolsHeader, RibbonGroup, RibbonItem, GroupedItems, CustomButton, ToolButton, ToggleElementButton, StatefulButton, PresetButton, Flyout, MainMenu, Zoom, PageControls. |
components/panels/ | Panels: thumbnails, outlines, notes, layers, signatures, search, style, form fields, stamps, links, text editing, color separation, redaction style. |
components/popups/ | Popups: annotation, text, content edit, snipping tool, context menu. |
components/modals/ | Dialogs: settings, password, signature, print, page editing, custom modals. |
components/overlays/ | Floating UI such as the page navigation and the form fill navigator. |
components/document/ | The document container. |
components/shared/ | Shared building blocks (buttons, icons, inputs). |
Headers, grouped items, buttons and flyouts are data in the viewer store. The default UI is defined in stores/defaults.ts:
default-top-header — navigation tools, the zoom control, the ribbon group default-ribbon-group and the menu button.tools-header — the grouped items of the active toolbar group, such as annotateGroupedItems and formsGroupedItems.MainMenuFlyout.You change them through instance.UI (see Header & Toolbar):
const header = instance.UI.getModularHeader('default-top-header');
console.log(header.getItems().map(item => item.dataElement));Popups render the items of instance.UI.annotationPopup, textPopup, contentEditPopup, snippingToolPopup and contextMenuPopup. See Popups.
Buttons accept the name of a built-in icon (for example Search, Download or LineTool) in img. CustomButton also accepts an image URL or an SVG string.
new instance.UI.Components.CustomElement({ dataElement, render }) renders any DOM element in a header.instance.UI.addPanel({ dataElement, location, render }) with a render function.instance.UI.addCustomModal(options).css option or instance.UI.setCustomStyle(cssText).const clock = new instance.UI.Components.CustomElement({
dataElement: 'clock',
render: () => {
const span = document.createElement('span');
span.textContent = new Date().toLocaleTimeString();
return span;
},
});
const header = instance.UI.getModularHeader('default-top-header');
header.setItems([...header.getItems(), clock]);