# @embedpdf/viewer ## 3.3.0 ### Minor Changes - [#1039](https://github.com/embedpdf/embed-pdf-viewer/pull/1039) by [@bobsingor](https://github.com/bobsingor) – `plugins.stamp.libraries` gives the viewer your own stamp libraries, each `{ id, url }` or `{ id, data }`, such as a check mark and a cross for ticking off a printed form: loaded when the viewer starts, never stored in the browser, and named in `quick` as `:` to show in the Insert toolbar. Quick stamps now show at the button's full height, so a wide stamp no longer shrinks to a few pixels. The `StampLibraryFile` type describes one library. A stamp library of your own as the standard stamps (`plugins.stamp.standard: '/my-stamps.pdf'`) no longer shows up once more in the stamps panel on every visit: it is never stored in the browser now, like the copy that ships, and `standard:` in `quick` finds its stamps. Copies already stored stay in the panel, where each can be removed. Fixes #1084. - [#1088](https://github.com/embedpdf/embed-pdf-viewer/pull/1088) by [@bobsingor](https://github.com/bobsingor) – `plugins.signature.revocation` keeps every signature the viewer seals checkable with no network: its validation data is stored in the file right after the seal. `plugins.signature.documentTimestamp` adds a document timestamp after it. `httpRevocationSource` and `createTestCertificateAuthority` are exported beside the signers. - [#1087](https://github.com/embedpdf/embed-pdf-viewer/pull/1087) by [@bobsingor](https://github.com/bobsingor) – `plugins.signature.timestampAuthority` gives every signature the viewer seals a timestamp. `httpTimestampAuthority` and `createTestTimestampAuthority` are exported beside the signers, so the authority comes from the same import as the key. ### Patch Changes - [#1092](https://github.com/embedpdf/embed-pdf-viewer/pull/1092) by [@bobsingor](https://github.com/bobsingor) – An Angular production build of an app with the viewer no longer warns that `pvtsutils` is not ESM. The signature package moved to `pkijs` 4 and `asn1js` 4, which no longer use it. An `allowedCommonJsDependencies` entry for `pvtsutils` can go. ## 3.2.0 ## 3.1.0 ### Minor Changes - [#1033](https://github.com/embedpdf/embed-pdf-viewer/pull/1033) by [@bobsingor](https://github.com/bobsingor) – A door can keep a document open under a new `src`: `DoorEngine.follows(opened, next)` says whether `next` names the same document as the one that is open, and the element then keeps it instead of opening it again. - [#1027](https://github.com/embedpdf/embed-pdf-viewer/pull/1027) by [@bobsingor](https://github.com/bobsingor) – `` takes `features`, in its config or as its own property (`element.features`), and follows it while the viewer runs. Measuring, redaction, building forms and snapshots now start off: `features: { measurement: true, redaction: true, 'forms.building': true, snapshots: true }` turns them on. `disable` and `element.disable` are deprecated and go in 4.0. ## 3.0.0 ### Major Changes - [#711](https://github.com/embedpdf/embed-pdf-viewer/pull/711) by [@bobsingor](https://github.com/bobsingor) – Introduces the complete EmbedPDF viewer as a custom element and CDN-ready artifact. It exposes `` and `EmbedPDF.init()`, bundles the shared viewer chrome, and wires in the local WASM engine by default. ### Minor Changes - [#948](https://github.com/embedpdf/embed-pdf-viewer/pull/948) by [@bobsingor](https://github.com/bobsingor) – `appState` is a live config key: your app's state, which your commands read as `appState`. Set it with `.appState`, in `.config`, or as `ViewerConfig`'s `appState`; a new value and every button asks its command again, in the same viewer. - [#891](https://github.com/embedpdf/embed-pdf-viewer/pull/891) by [@bobsingor](https://github.com/bobsingor) – The viewer brings the attachment plugin: `viewer.get('attachment')` lists, adds, removes and saves the files a document carries, and the sidebar has the attachments panel. - [#885](https://github.com/embedpdf/embed-pdf-viewer/pull/885) by [@bobsingor](https://github.com/bobsingor) – The viewer includes the outline plugin and its panel: `viewer.get('outline')` reads and edits the document's bookmarks. - [#941](https://github.com/embedpdf/embed-pdf-viewer/pull/941) by [@bobsingor](https://github.com/bobsingor) – `fonts` is a top-level setting: `EmbedPDF.init({ fonts: [{ key, url, label }] })`. The local door's `engine` options no longer take `fonts`, and a door's engine provider returns no fonts (`DoorEngine`). Depends on `@embedpdf/core-fonts`, which the viewer's chrome now imports. - [#869](https://github.com/embedpdf/embed-pdf-viewer/pull/869) by [@bobsingor](https://github.com/bobsingor) – The form designer: the Form mode opens for filling in, and **Form design** (`form:design`) switches design on, with a sidebar that lists the fields by page, shows the selected field's settings, and adds buttons to a radio group or boxes to a checkbox next in line. A field's look is in the Style sidebar, on the Form toolbar too. Selecting a field in the Form mode works again: the form plugin no longer misses the annotation plugin. - [#869](https://github.com/embedpdf/embed-pdf-viewer/pull/869) by [@bobsingor](https://github.com/bobsingor) – `` looks the same on every page. Borders, shadows and rings draw on pages without Tailwind of their own; every size is in px, so the page's `html { font-size }` no longer resizes the viewer; the text styles a page's `body` passes down (font, size, letter spacing, italics, weight, alignment, color scheme) no longer reach inside. Dialogs and click-away backdrops cover the viewer, not the page around it. A `--epdf-*` variable set on the element or on any element around it now wins in light and in dark, over the viewer's defaults and over `theme.tokens`, which apply when the page sets none. The viewer runs under the strict Content Security Policy on the Security page, with Trusted Types enforced: no `'unsafe-inline'`, no `'unsafe-eval'`, `worker-src 'self'`. The CDN folder now carries `embedpdf-worker.js` and `encoder-worker.js` beside `embedpdf.wasm`; served from your own origin they start as files, and loaded from a CDN the engine starts them from `blob:` URLs (`worker-src blob:`). The npm build leaves `@embedpdf/core`, the plugins and `@embedpdf/web` to your bundler instead of carrying its own copies, and lists them as dependencies. Your app and the viewer load one copy of each, so the headless hooks of your own `@embedpdf/react` work in the components you put inside the viewer, and your bundle gets smaller. - [#869](https://github.com/embedpdf/embed-pdf-viewer/pull/869) by [@bobsingor](https://github.com/bobsingor) – The style panel, its flags, a form field's settings, the link editor and the thumbnails' tooltips are translated in all 13 languages, by keys an app can change in `strings` (`'annotation.style.stroke'`, `'form.settings.tooltip'`). Readers of Traditional Chinese see English rather than Simplified Chinese. The Go to Page dialog reads "Page [3] of 8" again. - [#869](https://github.com/embedpdf/embed-pdf-viewer/pull/869) by [@bobsingor](https://github.com/bobsingor) – Ctrl/Cmd+F is Find (`search:find`): it opens search with the cursor in its field and the text selected, keeps it open, and works from any text field in the viewer, so pressing it again selects the search text instead of opening the browser's find. The Search button puts the cursor in the field too. `viewer.get('shell').open(id, { focus: true })` opens a panel asking for the cursor; a plain `open(id)` leaves it where it is. - [#827](https://github.com/embedpdf/embed-pdf-viewer/pull/827) by [@bobsingor](https://github.com/bobsingor) – Export MeasurementToken through every viewer entry point so applications can access page calibration and measurement controls through the viewer handle. - [#869](https://github.com/embedpdf/embed-pdf-viewer/pull/869) by [@bobsingor](https://github.com/bobsingor) – A door may say how its documents open and what plugin settings its engine needs: `DoorEngine.sourceOf` turns a `src` in its engine's words (the cloud's `{ token }`) into what the engine opens, for `src`, `documents` and `.src =`, and `DoorEngine.plugins` goes under the config's own, plugin by plugin. `ElementSrc` takes a door's own documents (the element reads only URLs, files, bytes and open inputs), and a document no door said how to open fails as `invalid-input` instead of being read as bytes. - [#957](https://github.com/embedpdf/embed-pdf-viewer/pull/957) by [@bobsingor](https://github.com/bobsingor) – The page number floating over the pages has previous and next page buttons around it, reads "3 / 12", and draws nothing for a document of one page. With pages side by side it reads "2–3 / 12" while the spread fits across the view, and Next goes to the next spread; zoomed in past it, it names the one page, and Next goes to the page beside it. It fades out once the pages and the pointer have been still for two seconds, at every size, and comes back when they move or the keyboard reaches it; a floating bar of yours does the same with `hideWhenIdle: true` in its place, which replaces `hideWhileScrolling`. Floating bars have the theme's corners instead of round ones. - [#817](https://github.com/embedpdf/embed-pdf-viewer/pull/817) by [@bobsingor](https://github.com/bobsingor) – Expose `AnnotationFontSpec` and `AnnotationsCustomization` through the viewer entry points so applications can configure additional FreeText fonts with `annotations.fonts`. - [#812](https://github.com/embedpdf/embed-pdf-viewer/pull/812) by [@bobsingor](https://github.com/bobsingor) – Expose `SignatureToken`, signer adapters, personal key stores, and signature customization types through the viewer's core entry point so applications can configure and control signing from the viewer package. - [#963](https://github.com/embedpdf/embed-pdf-viewer/pull/963) by [@bobsingor](https://github.com/bobsingor) – The bar over selected text sits below it, like the one over a selected annotation, and above it only without room below. The style panel no longer shows an annotation's flags; the `annotationFlags.*` keys in `strings` are gone with it. - [#923](https://github.com/embedpdf/embed-pdf-viewer/pull/923) by [@bobsingor](https://github.com/bobsingor) – The `fetch` config key: your own `fetch` for every document at a URL (`src`, `documents` and `{ kind: 'url' }` in code), to add headers or cookies. It follows its prop, as `element.fetch` too: the next download uses a new one, and the viewer stays. A server that answers 401 or 403 shows in the tab as not allowed, and **Try again** calls `fetch` again. - [#869](https://github.com/embedpdf/embed-pdf-viewer/pull/869) by [@bobsingor](https://github.com/bobsingor) – The `layout` config replaces `chrome`: a layout, or `(layout, env) => layout` with the viewer's env (`size`, `width`, `touch`, `dir`), run again when the viewer's size changes. `defaultLayout`, `createLayout` and the layout types (`Layout`, `LayoutEnv`, `LayoutData` and the rest) are exported; `defaultChrome`, `defineChrome`, `chromeHelpers`, `validateChrome` and the bar sugar are removed. The viewer's commands use the documented ids (`tool:highlight`, `view:rotate-clockwise`, `menu:document`, `panel:thumbnails`…) and belong to the documented features, so `disable: ['annotations.highlight']` turns off the highlighter everywhere. A user whose scope doesn't allow something doesn't see its tools, and Ctrl/Cmd+P without printing, or Ctrl/Cmd+C on text the user may not copy, shows a short notice instead of printing or copying the page. `` follows five keys while it runs: `src`, `theme`, `locale`, `disable` and `readOnly` change in place, whether they come from `.config`, from the element's own properties (`element.src = file`, `.theme`, `.locale`, `.disable`, `.readOnly`) or from the `src`, `theme` and `locale` attributes. A new `src` opens in place of the old document, at its tab position, and `null` closes it; `theme` swaps the token sheet and the mode, `locale` the language. Any other change still builds a new viewer. The viewer, and `element.viewer`, stay the same objects across live changes. `.config` now goes over the attributes instead of replacing them, so `` keeps its document when a script sets `.config` without one. `src` takes a URL, a `File` (any `Blob`) or the PDF's bytes (`ArrayBuffer` or `Uint8Array`, copied, so your buffer stays usable). The config takes `disable` (features such as `'annotations'` or `'annotations.highlight'`, and single commands such as `'tool:highlight'`, in one list; it replaces `disabledCategories`), `readOnly` (`true`, or `{ except: ['forms.filling'] }`), `scope` and `identity` for every document the viewer opens, and `notAllowed: 'hide' | 'disable'`. `element.viewer` is the `Viewer`: `get(name)` returns a plugin's API by its name (`viewer.get('search')`), or by its token as before, `viewer.documents` and `viewer.commands` are the documents and commands plugins with their events, and `watch` and `forDocument` stay. `on()`, `execute()`, `resolve()` and `watchCommand()` are removed: use `viewer.documents.onOpened(…)`, `viewer.commands.execute(id)` and `viewer.commands.resolveCommand(id)`. The `Viewer` type replaces `ViewerHandle`, and `ScopedViewer` replaces `ScopedViewerHandle`. New type exports: `DocumentSrc`, `LiveConfigKey`, `Feature`, `ReadOnlyExceptions`, `Identity`, `ViewerPlugins`, `PluginName`, `CommandsCapability`, `NotAllowedMode`. - [#949](https://github.com/embedpdf/embed-pdf-viewer/pull/949) by [@bobsingor](https://github.com/bobsingor) – Tooltips are the viewer's own, not the browser's: in the theme's font and its new `tooltip` and `tooltip-text` colors, above everything in the top layer, with a command's shortcut written the way the platform writes it, and why it can't run when it can't. Every button has one, in the toolbars, menus, panels and dialogs, and a name too long for its row shows whole while it's cut short. A command's button in the layout takes `emphasis: 'primary'`, filled in the accent, for the one thing its bar is for, and each toolbar is a part, `toolbar toolbar-`, for your CSS (`::part(toolbar-annotate)`). `` and `` take `active`, shown pressed or checked, and `` draws one of the viewer's icons, or one of yours, in your own components. The theme has `page-background` and `page-shadow` tokens, and `light` beside `dark`: token values for light mode only. Panels: a built-in panel's id brings its title and icon wherever it is in a layout, even a whole layout of yours; one string (`strings['panel:comments']`) or one `title` (`layout.panel('comments', { title })`) renames its header and its button together. `layout.panel(id, { open: true })` opens a panel when a document opens, where it docks, and `closable: false` keeps it open there. A panel over the pages resizes from its edge as a docked one does, and on a viewer wider than a phone a sheet is as wide as the panel's `width`, in the middle. Layout: bars floating on one edge share it instead of covering each other. `removeBar()` takes a list and takes out the bars riding along a removed one. `{ custom: 'id', grow: true }` gives your own component the rest of its bar. A floating bar's place takes `hideWhileScrolling`. Two config keys, read once: `size` lays the viewer out for one size at every width (`'compact'`, a phone's layout, `'medium'` or `'expanded'`), and `touch: true` gives every pointer 44 px buttons and menu rows (`false` none, `'auto'` asks the browser). The viewer in code: `get()` of a document's plugin before its document opens throws `PluginError('not-ready')`, and `watch()` waits through it, starting once the document has opened and waiting again after it closes. `watch(read, onChange, { immediate: true })` calls back with the first value too, and its third argument is now `{ immediate, isEqual }` (`WatchOptions`). `warnBeforeLeaving: false` leaves the page without asking, unsaved changes or not. While pages sit side by side, the page number reads "Pages 1–2 of 8", in every language (`pageNumber.page`, `pageNumber.pages`, `pageNumber.goToPage`), and the comments panel's words have their own keys (`comments.*`) in place of `demo.*`. A command's `enabled`, `active` or `visible` that throws counts as `false`. - [#869](https://github.com/embedpdf/embed-pdf-viewer/pull/869) by [@bobsingor](https://github.com/bobsingor) – New `@embedpdf/viewer/portable`: the viewer with the engine's portable build, for toolchains that can't emit the engine's files, such as plain esbuild. Import it in place of `@embedpdf/viewer`; the surface and the config are the same. The WebAssembly comes as a lazy chunk of your own build and both workers start from `blob:` URLs, so a strict policy needs `worker-src blob:` (or copy the two worker files and set `engine.worker` and `engine.encoderWorker`). Nothing is requested from another origin. The npm entries also no longer leave a bare import of a side-effect-free package behind, which esbuild warned about. - [#1004](https://github.com/embedpdf/embed-pdf-viewer/pull/1004) by [@bobsingor](https://github.com/bobsingor) – `strings` takes a language's words as a function too, such as `sv: () => import('./sv.json')`: they load the first time the viewer shows that language, which shows once they're in. `plugins.i18n.fallbackLocale` sets the fallback language, one of the viewer's or one of yours: the language a browser gets when the viewer has none of its languages, and where every word the current language doesn't have comes from. It loads at the start. `plugins.i18n` takes only `fallbackLocale` now; the languages are `locale` and `strings`, and other keys are left out with a warning. The viewer's English words ship as `@embedpdf/viewer/strings/en.json`, to start a translation from. A download is saved under the document's name instead of `document.pdf`. - [#869](https://github.com/embedpdf/embed-pdf-viewer/pull/869) by [@bobsingor](https://github.com/bobsingor) – Toolbars go anywhere the layout puts them: vertical bars along the left and right edges (`place: 'start'` or `'end'`, swapped in a right-to-left language), several bars on one edge in order, and bars floating over the pages (`place: { float: 'bottom-end' }` and the other seven positions). The page number floats at the bottom of the pages as the `pager` bar, and pressing it lets you type the page to go to. The document tabs now show only while more than one document is open; `layout.tabs('always')` brings back a tab for a single document. `onReady` and `onDocumentChange` are config keys, read once like the others: `onReady` gets the `viewer` once it's live, and `onDocumentChange` gets the active document's id whenever it changes, the first one included, and `null` once the last one closes. The element's `epdf:ready` and `epdf:documentchange` fire at the same moments, each just before its callback; `epdf:ready` now comes before the first `epdf:documentchange`. `@embedpdf/plugin-history` is listed as a dependency: the viewer's undo and redo use it. - [#869](https://github.com/embedpdf/embed-pdf-viewer/pull/869) by [@bobsingor](https://github.com/bobsingor) – Panels come from the layout: move one with `layout.panel('thumbnails', { side: 'end' })`, add your own with `layout.addPanel('notes', { title: 'Notes', icon: 'book' })` and its `panel:notes` button comes with it, and `layout.removePanel(id)` takes one out with its button. One panel shows per side, both sides at once; the header of an open panel switches between the panels on its side; a panel whose feature you turn off closes, live; and each document keeps its own open panels. A panel's body is the slot `panel:`. Panels open the way the viewer's size calls for: docked beside the pages in a wide viewer, with an edge you drag to make them wider or narrower (the width is kept while the viewer runs), over the pages' edge at medium widths, where only the pages dim and the toolbars keep working, and as a sheet from the bottom on a phone, which its handle drags taller, shorter or closed. A panel's `present` chooses one for every size, or for the sizes it names (`{ compact: 'overlay' }`: no sheet on a phone), and `layout.panels(changes)` changes every panel at once. `width` is where a panel starts (`360`) or that and how far it drags (`{ initial, min, max }`), `resizable: false` takes its edge away, and `onPanelResize` (the element's `epdf:panelresize`) tells you each width the user gives a panel, to keep for next time. The thumbnails wrap into more columns as their panel widens; `plugins.thumbnails` takes their Stage settings and `viewer.get('thumbnails')` is their Stage. The thumbnails and the search results close from a sheet or an overlay once you pick something in them. On a phone, menus open as sheets too, with submenus sliding in over them and a Back row, and the page number hides while you scroll. With a finger as the main pointer, every button and menu row is at least 44 px tall, and a viewer that reaches the edge of the screen keeps clear of the notch and the home bar. Sheets and dialogs take focus when they open, keep it until they close, close on Escape, and give focus back to the button that opened them; an overlay does the same but lets Tab move on to the toolbars; docked panels are labeled regions. Your own components in plain HTML: give a child of `` the slot `item:` (a toolbar item), `panel:` (a panel's body), or a region's name (`header`, `footer`, `tabs`, `empty`). A toolbar item's element carries where it sits as `data-orientation`, `data-edge`, `data-variant` and `data-size`, for your CSS. The viewer's own components come with it: `` is that command's button (or give it `icon` and `label`, and handle its click), and `` opens a menu of its `` rows the way the viewer's menus open, firing `select` on the row picked. They're drawn with the viewer's look and tokens, from constructed stylesheets (no `