pdfjs-viewer-element 3.1.1 → 3.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -14,11 +14,11 @@ Supported in all [major browsers](https://caniuse.com/custom-elementsv1), and wo
|
|
|
14
14
|
|
|
15
15
|
## Features
|
|
16
16
|
|
|
17
|
-
- Standalone web component with no runtime dependencies
|
|
17
|
+
- Standalone isolated web component with no runtime dependencies
|
|
18
18
|
- Drop-in, iframe-based PDF.js default viewer for any web app
|
|
19
19
|
- Works with same-origin and cross-origin PDF documents
|
|
20
20
|
- Configure via attributes and URL parameters (page, zoom, search, pagemode, locale)
|
|
21
|
-
- Programmatic access to `PDFViewerApplication`
|
|
21
|
+
- Programmatic access to `PDFViewerApplication` via the `initPromise` public property
|
|
22
22
|
- Theme control (automatic/light/dark) plus custom CSS injection
|
|
23
23
|
- Locale override support using PDF.js viewer locales
|
|
24
24
|
- Supports all modern browsers and most JS frameworks
|
|
@@ -86,8 +86,9 @@ The element is block-level and needs an explicit height.
|
|
|
86
86
|
| `zoom` | Zoom level (for example `auto`, `page-width`, `200%`). | `''` |
|
|
87
87
|
| `pagemode` | Sidebar mode: `thumbs`, `bookmarks`, `attachments`, `layers`, `none`. | `none` |
|
|
88
88
|
| `locale` | Viewer UI locale (for example `en-US`, `de`, `uk`). [Available locales](https://github.com/mozilla/pdf.js/tree/master/l10n) | `''` |
|
|
89
|
+
| `locale-src-template` | Locale file URL template. Must contain `{locale}` placeholder. Used together with `locale`. | `https://cdn.jsdelivr.net/gh/mozilla-l10n/firefox-l10n@main/{locale}/toolkit/toolkit/pdfviewer/viewer.ftl` |
|
|
89
90
|
| `viewer-css-theme` | Viewer theme: `AUTOMATIC`, `LIGHT`, `DARK`. | `AUTOMATIC` |
|
|
90
|
-
| `worker-src` | PDF.js worker URL override. |
|
|
91
|
+
| `worker-src` | PDF.js worker URL override. | `<package-url>/pdf.worker.min.mjs` |
|
|
91
92
|
|
|
92
93
|
Play with attributes on [API docs page](https://alekswebnet.github.io/pdfjs-viewer-element/#api).
|
|
93
94
|
|
|
@@ -101,6 +102,41 @@ Most attributes can be updated dynamically:
|
|
|
101
102
|
- `worker-src` updates viewer options for subsequent document loads.
|
|
102
103
|
- `locale` rebuilds the viewer so localization resources can be applied.
|
|
103
104
|
|
|
105
|
+
## Worker source
|
|
106
|
+
|
|
107
|
+
By default, the component resolves `worker-src` to the worker shipped with this package (`pdf.worker.min.mjs` in `dist`).
|
|
108
|
+
|
|
109
|
+
Set `worker-src` only if you want to serve the worker from a custom location (for example your own CDN or static assets path).
|
|
110
|
+
|
|
111
|
+
- The URL must point to a valid PDF.js module worker file.
|
|
112
|
+
- The worker version should match the bundled PDF.js version.
|
|
113
|
+
|
|
114
|
+
```html
|
|
115
|
+
<pdfjs-viewer-element
|
|
116
|
+
src="/file.pdf"
|
|
117
|
+
worker-src="https://cdn.jsdelivr.net/npm/pdfjs-dist@5.5.207/build/pdf.worker.min.mjs">
|
|
118
|
+
</pdfjs-viewer-element>
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Locale source template
|
|
122
|
+
|
|
123
|
+
Use `locale-src-template` when you need to load localization files from a custom host.
|
|
124
|
+
|
|
125
|
+
- The template must include `{locale}`.
|
|
126
|
+
- `{locale}` is replaced by the `locale` attribute value (for example `de`, `uk`, `en-US`).
|
|
127
|
+
- If `locale` is not set, no locale file is loaded.
|
|
128
|
+
- Changes to `locale-src-template` are applied when the viewer is (re)initialized, for example after setting/changing `locale`.
|
|
129
|
+
|
|
130
|
+
Example:
|
|
131
|
+
|
|
132
|
+
```html
|
|
133
|
+
<pdfjs-viewer-element
|
|
134
|
+
src="/file.pdf"
|
|
135
|
+
locale="de"
|
|
136
|
+
locale-src-template="https://cdn.example.com/pdfjs-locales/{locale}/viewer.ftl">
|
|
137
|
+
</pdfjs-viewer-element>
|
|
138
|
+
```
|
|
139
|
+
|
|
104
140
|
## Viewer CSS theme
|
|
105
141
|
|
|
106
142
|
Use `viewer-css-theme` attribute to set light or dark theme manually:
|
|
@@ -213,7 +249,7 @@ You can also react to source changes dynamically:
|
|
|
213
249
|
|
|
214
250
|
```javascript
|
|
215
251
|
const viewerElement = document.querySelector('pdfjs-viewer-element')
|
|
216
|
-
|
|
252
|
+
viewerElement.setAttribute('src', '/another-file.pdf')
|
|
217
253
|
```
|
|
218
254
|
|
|
219
255
|
## Accessibility
|