@@ -14,7 +14,7 @@ Supported in all [major browsers](https://caniuse.com/custom-elementsv1), and wo
1414
1515## Features
1616
17- - Standalone web component with no runtime dependencies
17+ - Standalone isolated web component with no runtime dependencies
1818- Drop-in, iframe-based PDF.js default viewer for any web app
1919- Works with same-origin and cross-origin PDF documents
2020- Configure via attributes and URL parameters (page, zoom, search, pagemode, locale)
@@ -86,8 +86,9 @@ The element is block-level and needs an explicit height.
8686| ` zoom ` | Zoom level (for example ` auto ` , ` page-width ` , ` 200% ` ). | ` '' ` |
8787| ` pagemode ` | Sidebar mode: ` thumbs ` , ` bookmarks ` , ` attachments ` , ` layers ` , ` none ` . | ` none ` |
8888| ` 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 ` |
8990| ` viewer-css-theme ` | Viewer theme: ` AUTOMATIC ` , ` LIGHT ` , ` DARK ` . | ` AUTOMATIC ` |
90- | ` worker-src ` | PDF.js worker URL override. | ` https://cdn.jsdelivr.net/npm/pdfjs-dist@5.4.624/build /pdf.worker.min.mjs` |
91+ | ` worker-src ` | PDF.js worker URL override. | ` <package-url> /pdf.worker.min.mjs` |
9192
9293Play with attributes on [ API docs page] ( https://alekswebnet.github.io/pdfjs-viewer-element/#api ) .
9394
@@ -101,6 +102,41 @@ Most attributes can be updated dynamically:
101102- ` worker-src ` updates viewer options for subsequent document loads.
102103- ` locale ` rebuilds the viewer so localization resources can be applied.
103104
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+
104140## Viewer CSS theme
105141
106142Use ` viewer-css-theme ` attribute to set light or dark theme manually:
@@ -213,7 +249,7 @@ You can also react to source changes dynamically:
213249
214250``` javascript
215251const viewerElement = document .querySelector (' pdfjs-viewer-element' )
216- viewer .setAttribute (' src' , ' /another-file.pdf' )
252+ viewerElement .setAttribute (' src' , ' /another-file.pdf' )
217253```
218254
219255## Accessibility
0 commit comments