Web Workers

PDFs can render page thumbnails in a Worker1. Passing thumbnailWorkerURL to UniverPdfsUIPlugin makes the Worker use OffscreenCanvas. This option does not move the entire PDF editor into a Worker.

Begin with installation and basic usage; the snippets below extend that setup. Register the plugins before creating or loading content, and update an existing registration rather than registering the same plugin twice.

Main thread

UniverPdfsUIPlugin

  • thumbnailWorkerURL
    string | URL | Worker
    Render thumbnails in a browser Worker.
TypeScript
import { UniverPdfsUIPlugin } from '@univerjs-pro/pdfs-ui'univer.registerPlugin(UniverPdfsUIPlugin, {  thumbnailWorkerURL: new Worker(new URL('./worker.ts', import.meta.url), { type: 'module' }),})

Worker entry

TypeScript
import { UniverPdfsUIWorkerPlugin } from '@univerjs-pro/pdfs-ui/worker'import { Univer } from '@univerjs/core'const univer = new Univer()univer.registerPlugin(UniverPdfsUIWorkerPlugin)

Use a module Worker with a separate entry file. Keep the package versions in the Worker and on the main thread aligned. Rendering and user interaction remain on the main thread.

Footnotes

  1. A Web Worker runs JavaScript outside the browser’s main thread and exchanges messages with it. It cannot access the page DOM directly; moving calculations into a Worker does not move the editor UI there. ↩

How is this guide?

© 2026 DreamNum Co., Ltd.