UI Overview
Configure the PDF canvas, editor controls, locale, and thumbnail worker.
@univerjs-pro/pdfs-ui mounts PDF units in the standard Univer workbench and is licensed through Univer Office SDK.
Package responsibilities
| Package | Responsibility |
|---|---|
@univerjs-pro/pdfs | Registers the UNIVER_PDF unit, the document model, and durable PDF commands. |
@univerjs-pro/pdfs-ui | Mounts the browser canvas, thumbnail rail, and footer; local editing controls are enabled by default. |
@univerjs-pro/pdfs-editor | Declares the editor dependencies on the collaboration side. It does not mount the PDF UI and does not control editor.enabled. |
UniverPdfsUIPlugin depends on UniverLicensePlugin and UniverPdfsPlugin, so complete the licensed PDF setup before registering the UI plugin.
Register the UI plugin
UniverPdfsUIPlugin
editorobjectPDF editor settings.enabledbooleanDefault:trueSet tofalsefor a read-only PDF viewer.
thumbnailWorkerURLstring | URL | WorkerRender thumbnails in a browser Worker.
import { UniverPdfsUIPlugin } from '@univerjs-pro/pdfs-ui'import PdfsUIEnUS from '@univerjs-pro/pdfs-ui/locale/en-US'import '@univerjs-pro/pdfs-ui/lib/index.css'univer.registerPlugin(UniverPdfsUIPlugin)Merge PdfsUIEnUS into the locales passed to new Univer(...). The locale pack translates the PDF-specific ribbon, inspector, context-menu, and page-rail labels.
Viewer and editor modes
With editing enabled, the plugin mounts the page-thumbnail rail, PDF canvas, and footer, and additionally registers the ribbon, context menus, inspector, clipboard, insertion commands, and editing actions and controllers.
Use viewer-only mode when the current application must not expose those editing controls:
univer.registerPlugin(UniverPdfsUIPlugin, { editor: { enabled: false },})With editor: { enabled: false } the plugin mounts only a continuous, virtualized read-only page view. The thumbnail rail, footer, ribbon, and inspector are not registered, so thumbnail navigation, the page controls in the footer, the zoom menu, and the Print action are not available from the UI. This option changes the mounted UI as well as the editing-specific controllers and services. It does not modify a saved PDF snapshot.
Mobile layout
The mobile plugin replaces the desktop workbench parts instead of wrapping them. It opens on a page-preview grid. Tap a page to edit it, and use the header for undo, redo, and page actions. Selecting content opens a floating toolbar for formatting and editing, and the read-only layout offers page count and zoom.
Register extension actions with the exported positions: PDF_MOBILE_VIEWER_MENU_POSITION for the viewing and editing layout, or PDF_MOBILE_EDITOR_MENU_POSITION for editing only.
Thumbnail worker
thumbnailWorkerURL accepts a string, URL, or existing Worker. The referenced module must start the exported worker runtime:
import { UniverPdfsUIWorkerPlugin } from '@univerjs-pro/pdfs-ui/worker'import { Univer } from '@univerjs/core'const univer = new Univer()univer.registerPlugin(UniverPdfsUIWorkerPlugin)univer.registerPlugin(UniverPdfsUIPlugin, { thumbnailWorkerURL: new URL('./pdf-thumbnail-worker.js', import.meta.url),})The worker requires a dedicated Worker scope. If no worker is configured, the browser lacks the required APIs, or a page depends on a resource that only the main thread can provide, thumbnails render on the main thread.
Public API boundary
The UI invokes PDF commands and services internally. A ribbon button does not imply a matching public method. For supported programmatic editing, use the PDF Facade guide; for conversion, use Import and export; for browser printing, use Print.
Menu order and grid layout
At startup, configure the order and grid placement in menu configuration. To change an existing menu, use the menu Facade API.
How is this guide?