Core Features
Univer PDFs provides a formal PDF unit, a durable edit layer, and a browser workbench. The imported PDF remains the baseline; accepted changes are stored in the unit snapshot and rendered as the current document.
Features
- PDF unit model: Stores the source document, page structure, resources, and durable editing intent in
IPdfUnitData. - Page and element operations: Inserts pages, navigates between pages, and works with editable text, lists, tables, images, dividers, and annotations.
- Browser workbench: Renders PDF pages and thumbnails, manages selection, editing controls, and clipboard behavior, and provides the inspector UI.
- Command pipeline: Applies accepted changes through durable commands and mutation batches, so save, undo, and redo operate on one model.
- Facade API: Creates, finds, edits, and saves PDF units through application-facing PDF, page, element, and native-text objects.
Plugin mode
Installation
pnpm add @univerjs/core @univerjs/design @univerjs/ui @univerjs-pro/license @univerjs-pro/pdfs @univerjs-pro/pdfs-uinpm install @univerjs/core @univerjs/design @univerjs/ui @univerjs-pro/license @univerjs-pro/pdfs @univerjs-pro/pdfs-uiyarn add @univerjs/core @univerjs/design @univerjs/ui @univerjs-pro/license @univerjs-pro/pdfs @univerjs-pro/pdfs-uibun add @univerjs/core @univerjs/design @univerjs/ui @univerjs-pro/license @univerjs-pro/pdfs @univerjs-pro/pdfs-uiUsage
import { UniverLicensePlugin } from '@univerjs-pro/license'import { UniverPdfsPlugin } from '@univerjs-pro/pdfs'import { UniverPdfsUIPlugin } from '@univerjs-pro/pdfs-ui'import PdfsUIEnUS from '@univerjs-pro/pdfs-ui/locale/en-US'import { LocaleType, mergeLocales, Univer } from '@univerjs/core'import { FUniver } from '@univerjs/core/facade'import DesignEnUS from '@univerjs/design/locale/en-US'import { UniverUIPlugin } from '@univerjs/ui'import UIEnUS from '@univerjs/ui/locale/en-US'import '@univerjs-pro/pdfs/facade'import '@univerjs/design/lib/index.css'import '@univerjs/ui/lib/index.css'import '@univerjs-pro/pdfs-ui/lib/index.css'const univer = new Univer({ locale: LocaleType.EN_US, locales: { [LocaleType.EN_US]: mergeLocales(DesignEnUS, UIEnUS, PdfsUIEnUS), },})univer.registerPlugin(UniverUIPlugin, { container: 'app' })univer.registerPlugin(UniverLicensePlugin, { license: process.env.CLIENT_LICENSE_TEXT,})univer.registerPlugin(UniverPdfsPlugin)univer.registerPlugin(UniverPdfsUIPlugin)const univerAPI = FUniver.newAPI(univer)const pdf = univerAPI.createPdf({ name: 'Untitled PDF' })Plugin configuration
UniverLicensePlugin
licensestringContents of the client license file.
UniverPdfsUIPlugin
editorobjectEnables the PDF editor or the Slides editor controls.enabledbooleanDefault:trueEnables the PDF editor or the Slides editor controls.
thumbnailWorkerURLstring | URL | WorkerRenders thumbnails in a browser Worker.
UniverPdfsPlugin owns the PDF unit and the durable commands. UniverPdfsUIPlugin owns the browser viewer and its editing controls. For viewer-only UI, register UniverPdfsUIPlugin with { editor: { enabled: false } }. Collaboration-backed applications can also register @univerjs-pro/pdfs-editor together with the collaboration plugins it requires.
Menu order and grid layout
UniverUIPlugin
containerstring | HTMLElementElement to mount into, or its DOM ID.ribbonTypeRibbonTypeDefault:classicSelects the Ribbon layout.
Configure menu and ribbonType in the existing UniverUIPlugin registration. These are shared UI options and do not belong to UniverPdfsUIPlugin. The example uses actual menu IDs from PDFs:
import type { MenuConfig } from '@univerjs/ui'import { UniverUIPlugin } from '@univerjs/ui'const menu: MenuConfig = { 'ribbon.view': { order: -1 }, 'ribbon.start.layout': { order: -1 }, 'pdf.menu.tool.highlight': { order: 1, gridLayout: { row: 2, column: 1 }, }, 'pdf.menu.tool.ink': { order: 0, gridLayout: { row: 1, column: 1 }, },}univer.registerPlugin(UniverUIPlugin, { container: 'app', ribbonType: 'grid', menu })order sorts sibling tabs, groups, or menu items in ascending order; it does not move an item between groups. Use the actual menu item ID, available from its data-u-command attribute, rather than assuming it is the command ID.
Preset mode
Univer PDFs does not currently provide a preset package. Create PDF applications in Plugin Mode.
Editing and viewing controls
The PDF Ribbon is built on the shared Univer ribbon. Start provides undo and redo, clipboard actions, the interaction-mode selector, page organization and insertion, and printing. Insert adds text boxes, images, paragraphs, dividers, tables, and lists. Annotations groups highlight, underline, and strikethrough with freehand drawing and pen options. View provides zoom, full screen, annotation visibility, continuous scrolling, and the properties panel. Selecting text, a table, or an image opens the matching contextual Text, Table, or Image tab, which also hosts the properties panel, table styling, and image transform actions. These Ribbon controls require the default editor.enabled: true setting in UniverPdfsUIPlugin.
Update menus with the Facade API
Runtime updates
Import @univerjs/ui/facade before creating univerAPI with FUniver.newAPI(univer). updateMenuConfig() merges the changes, preserves unspecified fields, and refreshes the menus. The overrides also apply to menus registered later.
import '@univerjs/ui/facade'univerAPI.updateMenuConfig({ 'pdf.menu.tool.highlight': { gridLayout: { row: 2, column: 1, showLabel: true, width: 96 } },})gridLayout affects only the grid Ribbon. Each group has two rows, and row and column start at 1. An explicit position takes precedence over the visual order set by order, so update both items when two occupied cells are swapped. Optional fields inherit the existing configuration or schema. See IRibbonGridLayout for spans, labels, widths, and icon sizes.
Keep editing enabled in UniverPdfsUIPlugin: editor.enabled: false skips registration of the product Ribbon, and menu overrides do not register missing buttons.
For custom buttons and submenu triggers, createMenu() and createSubmenu() also accept order and gridLayout; appendTo() registers them. The popup content does not use the Ribbon grid layout.
How is this guide?