You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit d4cdc19
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: src/_data/pdfjsAttributes.js
+8-1Lines changed: 8 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -89,7 +89,7 @@ export default [
89
89
{
90
90
name: "assets-base",
91
91
group: "files",
92
-
description: "Folder URL of the package's `dist` files: the five runtime files and the PDF.js data folders. Needed when your bundler doesn't emit the files, when a bundled app's documents need the data, or to load everything from a CDN. See [Bundlers](#bundlers-and-assets-base).",
92
+
description: "Folder URL of the package's `dist` files: the runtime files and the PDF.js data folders. Needed when your bundler doesn't emit the files, when a bundled app's documents need the data, or to load everything from a CDN. See [Bundlers](#bundlers-and-assets-base).",
93
93
default: "Folder of `pdfjs-viewer-element.js`",
94
94
update: "init",
95
95
},
@@ -100,6 +100,13 @@ export default [
100
100
default: "Bundled `pdf.worker.min.mjs`",
101
101
update: "load",
102
102
},
103
+
{
104
+
name: "renderer-src",
105
+
group: "files",
106
+
description: "PDF.js renderer worker module URL, used only when [worker rendering](#worker) is on. Must match the bundled PDF.js version.",
Copy file name to clipboardExpand all lines: src/pdfjs-viewer/index.md
+10-2Lines changed: 10 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -209,7 +209,7 @@ If your page has a Content Security Policy, allow the locale file's origin in `c
209
209
210
210
## Hosting
211
211
212
-
The element loads the viewer at runtime from five files next to `pdfjs-viewer-element.js` in the package's `dist` folder: `viewer.mjs`, `pdf.mjs`, `pdf.worker.min.mjs`, `viewer.css` and `paper-and-ink.css`. All of them must come from the same release as the element. The [data some PDFs need](#cmaps-fonts-and-other-resources) sits beside them.
212
+
The element loads the viewer at runtime from five files next to `pdfjs-viewer-element.js` in the package's `dist` folder: `viewer.mjs`, `pdf.mjs`, `pdf.worker.min.mjs`, `viewer.css` and `paper-and-ink.css`. All of them must come from the same release as the element. The [data some PDFs need](#cmaps-fonts-and-other-resources) sits beside them. With [worker rendering](#worker) on, the viewer also loads `pdf.renderer.min.mjs` from the same folder.
213
213
214
214
### Bundlers and `assets-base`
215
215
@@ -276,6 +276,8 @@ If your pipeline renames files, for example with content hashes, set each runtim
276
276
</pdfjs-viewer-element>
277
277
```
278
278
279
+
If you turn on [worker rendering](#worker), set `renderer-src` too.
280
+
279
281
The data folders are looked up next to `viewer-src`, and the scripting sandbox next to `pdfjs-lib-src`. Copy `cmaps/`, `standard_fonts/`, `wasm/`, `iccs/`, `images/` and `pdf.sandbox.mjs` from `dist` there and keep their names unhashed, because PDF.js loads them by name. Or point the [resource attributes](#pdf-js-resources) somewhere else.
280
282
281
283
### Worker
@@ -291,6 +293,10 @@ Set `worker-src` only to serve the worker from somewhere else, and use the match
291
293
</pdfjs-viewer-element>
292
294
```
293
295
296
+
PDF.js can also draw pages in a second worker, off the main thread. This is off by default. To turn it on, call [`setViewerOptions({ disableWorkerRendering:false })`](#setvieweroptions-options) right after you add the element.
297
+
298
+
That worker runs the bundled `pdf.renderer.min.mjs`. PDF.js starts it from a `blob:` URL too, so it needs the same Content Security Policy as the main worker. Set `renderer-src` only to serve the file from somewhere else, and use the matching PDF.js version ({{ pdfjsViewer.pdfjsVersion }}). If the worker can't start, PDF.js logs a "Renderer worker disabled" warning and draws on the main thread.
299
+
294
300
### CMaps, fonts and other resources
295
301
296
302
Most PDFs render with just the viewer files. Some need extra PDF.js data: CMaps for some CJK text, standard fonts for non-embedded base fonts, WASM decoders for JBIG2, CCITT and JPEG 2000 images, ICC color profiles, annotation icons, and the scripting sandbox for PDFs with JavaScript. All of it ships in the package and loads only for documents that need it.
@@ -350,7 +356,8 @@ import type { PdfjsViewerElement } from '@missing-elements/pdfjs-viewer'
- **From 4.4.2 or earlier:** version 4.5 moved from PDF.js 6.4 to 6.5. If you set `worker-src`, point it at `pdfjs-dist@{{ pdfjsViewer.pdfjsVersion }}`. TypeScript now rejects a bare `Uint8Array` in `viewerApp.open()`, which already failed at runtime. Pass `{ data }`, as in [Open a PDF from bytes](#open-a-pdf-from-bytes).
501
509
- **From 4.4.0 or earlier:** if your Content Security Policy allows `blob:` in `connect-src` only for locales, you can remove it.
502
510
- **From 4.3 or earlier:** if you worked around region locales with a lowercase code and lowercase locale folders, rename the folders back to their original case, such as `pt-BR`, and use any case in `locale`. PDF JavaScript now runs; see [PDF.js resources](#cmaps-fonts-and-other-resources) to turn it off. Absolute resource URLs keep working, and `debugger-src` is gone (it never had an effect).
503
511
- **From 3.x:** version 4 moved from PDF.js 5 to PDF.js 6. If you set `worker-src`, point it at `pdfjs-dist@{{ pdfjsViewer.pdfjsVersion }}`. From 3.0.x, also replace `viewer-extra-styles` and `viewer-extra-styles-urls` with [`injectViewerStyles()`](#injectviewerstyles-css).
0 commit comments