` of their own. Now there's no `
`: your class and style
go on the viewer itself.
- **Six keys follow their prop:** `src`, `theme`, `locale`, `features`, `readOnly` and `fetch`.
2.x's framework packages read the config once. Every other key is still read once: see
[Change the config later](setup#change-the-config-later).
- **Server-side rendering needs no wrapper.** Every framework package is safe to import on the
server, so a `` or a dynamic import around the viewer can go. See
[Setup](setup#server-side-rendering).
2.x had no Angular package. In 3.0, the viewer is the `EpdfPdfViewer` component,
``: each config key is an input, or give them all at once with `[config]`.
## The config, key by key
| 2.x | 3.0 |
| :-- | :-- |
| `src` | `src`: a URL, a `File` or bytes |
| `documentManager.initialDocuments` | `documents`, each with `src`, `name`, `password` and `active`, in place of `url`, `name`, `password` and `autoActivate` |
| A document's `requestOptions`: `headers` and `credentials` | `fetch`, your own, which every document at a URL downloads through: see [Files that need a sign-in](documents#files-that-need-a-sign-in) |
| `tabBar` | `layout.tabs()` in the [layout](customize/layout): `'always'`, `'multiple'` (the default) or `'never'` |
| `theme` | `theme`, with new keys: see [Theme](#theme) |
| `icons` | `icons`, as path data: see [Buttons and the toolbar](#buttons-and-the-toolbar) |
| `commands.commands` | `commands`, a list |
| `ui.schema` | `layout` |
| `disabledCategories` | `features`, with new names: see [Turn features on and off](#turn-features-on-and-off) |
| `permissions` | `scope`: see [Permissions](#permissions) |
| `i18n.defaultLocale` | `locale` |
| `i18n.locales` | `strings`: words by language code, with a button's label under its command's id, or a function that loads them: see [Translations](customize/translations) |
| `i18n.fallbackLocale` | `plugins.i18n.fallbackLocale`, which is also the language a browser gets when the viewer has none of its languages |
| `export.defaultFileName` | The document's `name`: a download is saved under it, as `name` from `documents` or the file's own name |
| `annotations.annotationAuthor` | `identity: { displayName }` |
| `wasmUrl` | `engine.wasmUrl`. The file is `embedpdf.wasm` now, from `@embedpdf/engine-runtime-wasm32`, in place of `pdfium.wasm`. |
| `fontFallback` | `engine.fallbackFonts`: font files, each with a `key` and a `url` |
| `fonts.ui` | `theme.tokens.font` |
| `fonts.signature` | `plugins.signature.fonts`: font files, each with a `key`, a `label` and a `url` |
| `stamp.manifests` | `plugins.stamp.standard`: `true`, a URL, or `false` for none |
| `fullscreen.targetElement` | Nothing: Full Screen fills the screen with the viewer. For an element of yours, give `view:fullscreen` your own `run`: see [Full screen](concepts/how-it-works#full-screen) |
| Every other plugin's key: `zoom`, `scroll`, `annotations`, … | `plugins`, under the 3.0 plugin's name: see [Plugin settings](#plugin-settings) |
### Plugin settings
The plugins' settings are new too. `plugins` takes them under the 3.0 plugin's name, as its page in
the headless docs lists them, with plain strings where 2.x had enums. The ones 2.x apps set most:
| 2.x | 3.0 |
| :-- | :-- |
| `zoom: { defaultZoomLevel: ZoomMode.FitWidth }` | `stage: { zoom: { mode: 'fit-width' } }` |
| `zoom: { minZoom: 0.5, maxZoom: 4 }` | `stage: { minZoom: 0.5, maxZoom: 4 }` |
| `zoom: { presets }` | The `zoom` menu: [change it](customize/menus#change-a-built-in-menu) |
| `scroll: { defaultStrategy: ScrollStrategy.Horizontal }` | `stage: { layout: 'horizontal' }` |
| `scroll: { defaultPageGap: 20 }` | `stage: { gap: 20 }` |
| `spread: { defaultSpreadMode: SpreadMode.Odd }` | `stage: { spread: 'odd' }` |
| `rotation: { defaultRotation: Rotation.Degree90 }` | `stage: { viewRotation: 90 }` |
| `pan: { defaultMode: 'always' }` | `interaction: { defaultTool: 'pan' }` |
| `thumbnails: { width: 120 }` | `thumbnails: { zoom: { pageWidth: 120 } }` |
| `annotations: { selectAfterCreate: false }` | `annotation: { afterCreate: { select: false } }` |
| `annotations: { deactivateToolAfterCreate: true }` | `annotation: { afterCreate: { tool: 'default' } }` |
| `stamp: { manifests: [] }` | `stamp: { standard: false }` |
| `stamp: { manifests: [{ url }] }`, your own | `stamp: { libraries: [{ id, url }] }`, with the PDF the manifest names: see [Your own stamps](features/annotations#your-own-stamps) |
| `capture: { scale: 2 }` | `render: { snapshot: { scale: 2 } }`. A snapshot is always PNG, with what the user may see drawn in. |
All of them in one 3.0 config:
```js
{
plugins: {
stage: {
zoom: { mode: 'fit-width' },
minZoom: 0.5,
maxZoom: 4,
layout: 'horizontal',
gap: 20,
spread: 'odd',
viewRotation: 90,
},
interaction: { defaultTool: 'pan' },
thumbnails: { zoom: { pageWidth: 120 } },
annotation: { afterCreate: { select: false, tool: 'default' } },
stamp: { standard: false },
},
}
```
[Plugins](code/plugins#every-plugin) links each plugin to its settings.
## From code
`onReady` gives you the [`viewer`](code/viewer) once it's live. `viewer.get('search')` is what
`registry.getPlugin('search').provides()` gave you in 2.x, and `viewer.documents` and
`viewer.commands` need no call at all.
| 2.x | 3.0 |
| :-- | :-- |
| `await container.registry`, or a ref's `registry` | `onReady`. In plain HTML, also `element.viewer` once the element fires `epdf:ready`. |
| `registry.getPlugin(id).provides()` | `viewer.get(name)` |
| `.forDocument(documentId)` on a plugin | `viewer.forDocument(documentId).get(name)` |
| `onInit`, with the container | None: what you did with the container is config now (`theme`, `icons`) |
| `registry.getEngine()` | None: the viewer keeps its engine. Read the document through the plugins instead, such as `viewer.get('metadata')`, and get the file with `viewer.documents.download()`. |
The plugins have new names:
| 2.x plugin | 3.0 plugin |
| :-- | :-- |
| `zoom`, `scroll`, `spread`, `rotate`, `viewport` | `stage` |
| `render`, `tiling` | `render` |
| `capture` | `render`, whose `snapshot` tool takes part of a page as an image |
| `thumbnail` | `thumbnails` |
| `bookmark` | `outline`, which also adds, renames, moves and deletes items |
| `attachment` | `attachment`, which also lists the files pinned to pages, and attaches and removes files |
| `document-manager`, `export` | `documents` |
| `interaction-manager`, `pan` | `interaction`, whose `pan` tool is the hand |
| `ui` | `shell` for what's open, and the config's `layout` for what goes where |
| `print`, `fullscreen`, `history` | No plugin: run their commands, `document:print`, `view:fullscreen`, `history:undo` and `history:redo` |
| `annotation`, `search`, `selection`, `form`, `redaction`, `stamp`, `signature`, `i18n`, `commands` | The same name |
Their methods are new as well, each on its plugin's page in the headless docs. The calls 2.x code
makes most:
| 2.x | 3.0 |
| :-- | :-- |
| `openDocumentUrl({ url })` | `viewer.documents.open({ kind: 'url', url })` |
| `openDocumentBuffer({ buffer, name })` | `viewer.documents.open({ kind: 'bytes', bytes: buffer }, { name })` |
| `setActiveDocument(id)`, `closeDocument(id)` | `viewer.documents.setActive(id)`, `viewer.documents.close(id)` |
| `onDocumentOpened(callback)` | `viewer.documents.onOpened(({ documentId }) => …)` |
| `saveAsCopy()` | `viewer.documents.download()`: the PDF's bytes |
| `download()` | `viewer.commands.execute('document:download')` |
| `scrollToPage({ pageNumber: 5 })` | `viewer.get('stage').goToPage(4)`: pages count from 0 |
| `setLocale('de')` | The `locale` prop |
| `toggleMarqueeCapture()` | `viewer.commands.execute('tool:snapshot')` |
| `onCaptureArea(callback)` | `viewer.get('render').onSnapshotChanged(({ snapshot }) => …)` |
## Theme
2.x set colors per mode, in groups: `theme.light.accent.primary`. 3.0 names each color once, as a
token, with `tokens` for both modes, `light` for light only and `dark` for dark only:
```js
{
theme: {
preference: 'system',
tokens: { radius: '4px' },
light: { accent: '#9333ea', canvas: '#f5f3ff' },
dark: { accent: '#a855f7', canvas: '#1e1b2e' },
},
}
```
2.x's `light` colors go in `light`, and its `dark` ones in `dark`:
| 2.x color | 3.0 token |
| :-- | :-- |
| `accent.primary` | `accent` |
| `background.app` | `canvas` |
| `background.surface` | `surface` |
| `background.elevated` | `surface-raised` |
| `foreground.primary` | `text` |
| `foreground.secondary` | `text-muted` |
| `border.default` | `border` |
| `interactive.hover` | `hover` |
The other 2.x colors, such as `accent.primaryHover` or `state.error`, have no token. For what tokens
don't cover, restyle a part with `::part()`: see [Theming](customize/theming#restyle-a-part).
The container's `setTheme()` is the `theme` prop now, which follows its value.
## Buttons and the toolbar
2.x changed the toolbar after the viewer started: `registerCommand()`, `registerIcon()`, then
`mergeSchema()` with a copy of the toolbar's items. In 3.0 all three are config, and the layout is
a function that gets the default and returns yours. Here is 2.x's example, a smiley in place of the
comments button:
```js
{
icons: {
smiley: [
'M3 12a9 9 0 1 0 18 0a9 9 0 1 0 -18 0',
'M9 10l.01 0',
'M15 10l.01 0',
'M9.5 15a3.5 3.5 0 0 0 5 0',
],
},
commands: [{ id: 'acme:hello', label: 'Say hello', icon: 'smiley', run: () => alert('Hello!') }],
layout: (layout) => layout.replace('panel:comments', 'acme:hello'),
}
```
| 2.x | 3.0 |
| :-- | :-- |
| `commands.registerCommand(command)` | `commands: [command]` |
| A command's `action` | `run` |
| `disabled` | `enabled`, which says the opposite |
| `shortcuts` | `shortcut` |
| `registry` and `state`, in a command's functions | `get`, which gives you any plugin by its name |
| The container's `registerIcon(name, { viewBox, paths })` | `icons`: 24 × 24 path data, each path a string |
| `ui.mergeSchema({ toolbars })` | `layout: (layout) => layout.add(…)`, `.remove(…)`, `.replace(…)` |
| `ui.toggleMenu()` in a command | `menu: 'id'` on the command |
| A `{ type: 'custom', componentId }` item | `{ custom: 'id' }`, with [your own component](customize/components) |
A command's `label`, `labelKey`, `icon`, `active`, `visible` and `categories` keep their names.
The ids changed:
| 2.x | 3.0 |
| :-- | :-- |
| `main-toolbar` | `main` |
| `annotation-toolbar`, `shapes-toolbar`, `insert-toolbar`, `form-toolbar`, `redaction-toolbar` | `annotate`, `shapes`, `insert`, `form`, `redact` |
| `document-menu`, `zoom-menu`, `page-settings-menu` | `document`, `zoom`, `view` |
| The `selection` and `annotation` selection menus | The `selection` and `annotation` bars |
| `document:export`, `document:fullscreen` | `document:download`, `view:fullscreen` |
| `annotation:add-highlight`, `panel:toggle-search`, `scroll:next-page` | `tool:highlight`, `panel:search`, `page:next` |
| `zoom:marquee` | `tool:zoom`, which switches to the `zoom` tool |
| `capture:screenshot` | `tool:snapshot`, which switches to the `snapshot` tool |
Every 3.0 id is on [Layout](customize/layout#every-built-in-id) and
[Buttons & commands](customize/commands#every-built-in-command).
## Turn features on and off
`disabledCategories` is `features`, with each name set to `false`. It takes 3.0's
[features](features/turning-off), with their parts after a dot:
| 2.x | 3.0 |
| :-- | :-- |
| `annotation` | `annotations` and `shapes`: 2.x's shapes were annotations |
| `annotation-highlight` | `annotations.highlight` |
| `annotation-ink` | `annotations.drawing` |
| `annotation-shape` | `shapes` |
| `insert-rubber-stamp`, `insert-image` | `stamps` |
| `insert-signature` | `signatures.signing` |
| `form` | `forms` |
| `redaction` | `redaction` |
| `panel-search` | `search` |
| `panel-comment` | `comments` |
| `selection-copy` | `text.copy` |
| `capture`, `capture-screenshot` | `snapshots` |
| `document-open`, `document-export`, `document-print` | `documents.open`, `documents.download`, `documents.print` |
| `zoom`, `rotate`, `spread`, `scroll`, `pan` | No feature: [remove](customize/layout#remove-buttons) their buttons, or turn each command off [everywhere](features/turning-off#one-button-everywhere), such as `'zoom:in'` |
In 2.x everything was on. Now measuring, redaction, building forms and snapshots start off, so turn
on what your 2.x viewer showed:
```js
{ features: { measurement: true, redaction: true, 'forms.building': true, snapshots: true } }
```
New in 3.0, `readOnly: true` turns off everything that changes the document.
## Permissions
2.x's `permissions` changed what the viewer offered. 3.0's `scope` is the list of what the user
[may do](features/turning-off#what-a-user-may-do), and the engine checks it on every call:
| 2.x | 3.0 |
| :-- | :-- |
| No `permissions`: the PDF's own restrictions count | No `scope`: the same |
| `enforceDocumentPermissions: false` | `scope: ['*']`: the user may do everything |
| `overrides: { print: true }` | `'doc.print'` added to the default scope, which [Permissions](/docs/headless/concepts/permissions) lists |
| `overrides: { print: false }` | A scope that leaves out both `'doc.print'` and `'pdf.permissions'`, or, for the button only, `features: { 'documents.print': false }` |
2.x's `print` is `doc.print` in a scope, `printHighQuality` is `doc.print.high`, `copyContents` is
`doc.text.copy` and `doc.content.copy`, `modifyAnnotations` is `doc.annotate.modify`, `fillForms` is `doc.forms.fill` and
`assembleDocument` is `doc.pages.assemble`. See [Permissions](/docs/headless/concepts/permissions).
## Security and self-hosting
### Nothing from a third party
2.x fetched several files from public servers. 3.0 fetches nothing from a third party unless you
point it there:
| 2.x fetched | 3.0 |
| :-- | :-- |
| `pdfium.wasm`, from jsDelivr | `embedpdf.wasm`, a file of your build |
| Fallback fonts, from jsDelivr | None, unless you give `engine.fallbackFonts` |
| The UI font and the signature fonts, from Google Fonts | The system font. The signature fonts are lazy chunks of your build. |
| The standard stamps, from jsDelivr | A lazy chunk of your build |
So a PDF whose text needs a font it doesn't embed, such as Chinese or Japanese, needs a fallback
font you give the engine: see [Fonts](/docs/engine/documents/fonts). Every file and its setting is
on [Self-hosting](self-hosting).
### Content Security Policy
2.x drew its styles from a `