Skip to content

Commit 23c59d5

Browse files
serpentbladeclaude
andcommitted
fix(ui-pdf): lazy-import pdfjs (SSR-safe + code-split) + top-level cancelled flag
PDF.js's main build evaluates browser globals (DOMMatrix, …) at module load, so a top-level `import * as pdfjsLib from 'pdfjs-dist'` crashes SSR (Next/Nuxt/ SvelteKit/Analog/VitePress — surfaced building the docs). Switch to a dynamic `import('pdfjs-dist')` inside $onMount: SSR-safe for ALL consumers AND it code-splits the ~1MB engine out of the initial bundle. The mount-teardown's `cancelled` guard is now a TOP-LEVEL let — the Solid emitter hoists the $onMount return into a sibling onCleanup() outside the mount closure, so a mount-local would be out of scope there. Also added a `standardFontDataUrl` prop (CDN default) so the base-14 fonts render with correct glyphs, and switched document teardown to the loading task (PDFDocumentProxy has no destroy() in v6). All 6 leaves build + strict-typecheck clean; compile()×6 zero-error. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent d849c2e commit 23c59d5

17 files changed

Lines changed: 217 additions & 103 deletions

File tree

packages/ui/pdf/packages/angular/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export class DemoComponent {
4747
| `scale` | `Number` | `1` | | |
4848
| `rotation` | `Number` | `0` | | |
4949
| `workerSrc` | `String` | `"https://cdn.jsdelivr.net/npm/pdfjs-dist@6.0.227/build/pdf.worker.min.mjs"` | | |
50+
| `standardFontDataUrl` | `String` | `"https://cdn.jsdelivr.net/npm/pdfjs-dist@6.0.227/standard_fonts/"` | | |
5051
| `renderAllPages` | `Boolean` | `false` | | |
5152
| `textLayer` | `Boolean` | `true` | | |
5253
| `password` | `unknown` | `undefined` | | |

packages/ui/pdf/packages/angular/src/PdfViewer.ts

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
11
import { Component, DestroyRef, ElementRef, Renderer2, ViewEncapsulation, afterRenderEffect, effect, forwardRef, inject, input, model, output, signal, untracked, viewChild } from '@angular/core';
22
import { NG_VALUE_ACCESSOR } from '@angular/forms';
33

4-
import * as pdfjsLib from 'pdfjs-dist';
5-
6-
// null-lets so the bundled-leaf typeNeutralize pass annotates them `any`:
7-
// `instance` is the PDFDocumentProxy (whose strict types the loosely-typed props
8-
// don't satisfy — routing the render chain through `any` is the maplibre
9-
// mapOptions idiom), containerEl is the scroll host, observer is the
10-
// continuous-mode scroll spy.
11-
124
@Component({
135
selector: 'rozie-pdf-viewer',
146
standalone: true,
@@ -80,6 +72,7 @@ export class PdfViewer {
8072
scale = input<number>(1);
8173
rotation = input<number>(0);
8274
workerSrc = input<string>('https://cdn.jsdelivr.net/npm/pdfjs-dist@6.0.227/build/pdf.worker.min.mjs');
75+
standardFontDataUrl = input<string>('https://cdn.jsdelivr.net/npm/pdfjs-dist@6.0.227/standard_fonts/');
8376
renderAllPages = input<boolean>(false);
8477
textLayer = input<boolean>(true);
8578
password = input<unknown>(undefined);
@@ -110,7 +103,7 @@ export class PdfViewer {
110103
effect(() => { const __watchVal = (() => this.src())(); untracked(() => { if (this.__rozieWatchInitial_0) { this.__rozieWatchInitial_0 = false; return; } (() => this._load())(); }); });
111104
effect(() => { const __watchVal = (() => this.password())(); untracked(() => { if (this.__rozieWatchInitial_1) { this.__rozieWatchInitial_1 = false; return; } (() => this._load())(); }); });
112105
effect(() => { const __watchVal = (() => this.workerSrc())(); untracked(() => { if (this.__rozieWatchInitial_2) { this.__rozieWatchInitial_2 = false; return; } ((v: any) => {
113-
if (v) pdfjsLib.GlobalWorkerOptions.workerSrc = v;
106+
if (this.pdfjsLib && v) this.pdfjsLib.GlobalWorkerOptions.workerSrc = v;
114107
})(__watchVal); }); });
115108
effect(() => { const __watchVal = (() => this.page())(); untracked(() => { if (this.__rozieWatchInitial_3) { this.__rozieWatchInitial_3 = false; return; } ((v: any) => {
116109
if (typeof v === 'number' && v >= 1 && v !== this.current()) this.current.set(v);
@@ -137,13 +130,23 @@ export class PdfViewer {
137130
}
138131

139132
ngAfterViewInit() {
140-
pdfjsLib.GlobalWorkerOptions.workerSrc = this.workerSrc();
133+
this.cancelled = false;
141134
this.containerEl = this.viewerEl()?.nativeElement;
142135
this.current.set(Math.max(1, this.page()));
143136
this.zoom.set(this.scale());
144137
this.rot.set(this.rotation());
145-
this._load();
138+
// lazy-load the engine (SSR-safe + code-split), then configure the worker and
139+
// load the document.
140+
// lazy-load the engine (SSR-safe + code-split), then configure the worker and
141+
// load the document.
142+
import('pdfjs-dist').then((mod: any) => {
143+
if (this.cancelled) return;
144+
this.pdfjsLib = mod;
145+
this.pdfjsLib.GlobalWorkerOptions.workerSrc = this.workerSrc();
146+
this._load();
147+
});
146148
this.__rozieDestroyRef.onDestroy(() => {
149+
this.cancelled = true;
147150
this.renderToken++;
148151
if (this.observer) {
149152
this.observer.disconnect();
@@ -157,14 +160,17 @@ export class PdfViewer {
157160
});
158161
}
159162

163+
pdfjsLib: any = null;
160164
instance: any = null;
161165
containerEl: any = null;
162166
observer: any = null;
163167
loadingTask: any = null;
164168
renderToken = 0;
165169
suppressScroll = false;
170+
cancelled = false;
166171
buildSource = () => {
167172
const __password = this.password();
173+
const __standardFontDataUrl = this.standardFontDataUrl();
168174
let cfg: any = null;
169175
cfg = {
170176
...this.options()
@@ -185,6 +191,7 @@ export class PdfViewer {
185191
cfg.data = src;
186192
}
187193
if (__password != null) cfg.password = __password;
194+
if (__standardFontDataUrl) cfg.standardFontDataUrl = __standardFontDataUrl;
188195
return cfg;
189196
};
190197
renderPage = async (pdf: any, pageNum: any, container: any) => {
@@ -218,7 +225,7 @@ export class PdfViewer {
218225
const tl = document.createElement('div');
219226
tl.className = 'textLayer';
220227
pageDiv.appendChild(tl);
221-
const layer = new pdfjsLib.TextLayer({
228+
const layer = new this.pdfjsLib.TextLayer({
222229
textContentSource: page.streamTextContent(),
223230
container: tl,
224231
viewport
@@ -291,6 +298,7 @@ export class PdfViewer {
291298
this.pagesrendered.emit();
292299
};
293300
_load = async () => {
301+
if (!this.pdfjsLib) return;
294302
const token = ++this.renderToken;
295303
if (this.observer) {
296304
this.observer.disconnect();
@@ -306,7 +314,7 @@ export class PdfViewer {
306314
if (this.containerEl) this.containerEl.innerHTML = '';
307315
if (!this.src()) return;
308316
try {
309-
this.loadingTask = pdfjsLib.getDocument(this.buildSource());
317+
this.loadingTask = this.pdfjsLib.getDocument(this.buildSource());
310318
this.loadingTask.onPassword = (_updatePassword: any, reason: any) => {
311319
this.passwordrequest.emit({
312320
reason

packages/ui/pdf/packages/lit/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ el.addEventListener('load', (e) => console.log(e.detail.numPages));
3535
| `scale` | `Number` | `1` | | |
3636
| `rotation` | `Number` | `0` | | |
3737
| `workerSrc` | `String` | `"https://cdn.jsdelivr.net/npm/pdfjs-dist@6.0.227/build/pdf.worker.min.mjs"` | | |
38+
| `standardFontDataUrl` | `String` | `"https://cdn.jsdelivr.net/npm/pdfjs-dist@6.0.227/standard_fonts/"` | | |
3839
| `renderAllPages` | `Boolean` | `false` | | |
3940
| `textLayer` | `Boolean` | `true` | | |
4041
| `password` | `unknown` | `undefined` | | |

packages/ui/pdf/packages/lit/src/PdfViewer.ts

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,6 @@ import { LitElement, css, html } from 'lit';
22
import { customElement, property, query } from 'lit/decorators.js';
33
import { SignalWatcher, effect, signal, untracked } from '@lit-labs/preact-signals';
44
import { createLitControllableProperty, injectGlobalStyles, rozieListeners, rozieSpread } from '@rozie/runtime-lit';
5-
import * as pdfjsLib from 'pdfjs-dist';
6-
7-
// null-lets so the bundled-leaf typeNeutralize pass annotates them `any`:
8-
// `instance` is the PDFDocumentProxy (whose strict types the loosely-typed props
9-
// don't satisfy — routing the render chain through `any` is the maplibre
10-
// mapOptions idiom), containerEl is the scroll host, observer is the
11-
// continuous-mode scroll spy.
125

136
@customElement('rozie-pdf-viewer')
147
export default class PdfViewer extends SignalWatcher(LitElement) {
@@ -66,6 +59,7 @@ export default class PdfViewer extends SignalWatcher(LitElement) {
6659
@property({ type: Number, reflect: true }) scale: number = 1;
6760
@property({ type: Number, reflect: true }) rotation: number = 0;
6861
@property({ type: String, reflect: true }) workerSrc: string = 'https://cdn.jsdelivr.net/npm/pdfjs-dist@6.0.227/build/pdf.worker.min.mjs';
62+
@property({ type: String, reflect: true }) standardFontDataUrl: string = 'https://cdn.jsdelivr.net/npm/pdfjs-dist@6.0.227/standard_fonts/';
6963
@property({ type: Boolean, reflect: true }) renderAllPages: boolean = false;
7064
@property({ type: Boolean, reflect: true }) textLayer: boolean = true;
7165
@property({ type: Object }) password: unknown = undefined;
@@ -87,6 +81,7 @@ private __rozieFirstUpdateDone = false;
8781

8882
firstUpdated(): void {
8983
this._disconnectCleanups.push((() => {
84+
this.cancelled = true;
9085
this.renderToken++;
9186
if (this.observer) {
9287
this.observer.disconnect();
@@ -118,19 +113,28 @@ private __rozieFirstUpdateDone = false;
118113
this._disconnectCleanups.push(effect(() => { const __watchVal = (() => this._zoom.value)(); untracked(() => { if (this.__rozieWatchInitial_7) { this.__rozieWatchInitial_7 = false; return; } (() => this.renderView())(); }); }));
119114
this._disconnectCleanups.push(effect(() => { const __watchVal = (() => this._rot.value)(); untracked(() => { if (this.__rozieWatchInitial_8) { this.__rozieWatchInitial_8 = false; return; } (() => this.renderView())(); }); }));
120115

121-
pdfjsLib.GlobalWorkerOptions.workerSrc = this.workerSrc;
116+
this.cancelled = false;
122117
this.containerEl = this._refViewerEl;
123118
this._current.value = Math.max(1, this.page);
124119
this._zoom.value = this.scale;
125120
this._rot.value = this.rotation;
126-
this.load();
121+
// lazy-load the engine (SSR-safe + code-split), then configure the worker and
122+
// load the document.
123+
// lazy-load the engine (SSR-safe + code-split), then configure the worker and
124+
// load the document.
125+
import('pdfjs-dist').then((mod: any) => {
126+
if (this.cancelled) return;
127+
this.pdfjsLib = mod;
128+
this.pdfjsLib.GlobalWorkerOptions.workerSrc = this.workerSrc;
129+
this.load();
130+
});
127131
}
128132

129133
updated(changedProperties: Map<string, unknown>): void {
130134
if (this.__rozieFirstUpdateDone && (changedProperties.has('src'))) { const __watchVal = (() => this.src)(); (() => this.load())(); }
131135
if (this.__rozieFirstUpdateDone && (changedProperties.has('password'))) { const __watchVal = (() => this.password)(); (() => this.load())(); }
132136
if (this.__rozieFirstUpdateDone && (changedProperties.has('workerSrc'))) { const __watchVal = (() => this.workerSrc)(); ((v: any) => {
133-
if (v) pdfjsLib.GlobalWorkerOptions.workerSrc = v;
137+
if (this.pdfjsLib && v) this.pdfjsLib.GlobalWorkerOptions.workerSrc = v;
134138
})(__watchVal); }
135139
if (this.__rozieFirstUpdateDone && (changedProperties.has('scale'))) { const __watchVal = (() => this.scale)(); ((v: any) => {
136140
if (typeof v === 'number' && v > 0) this._zoom.value = v;
@@ -164,6 +168,8 @@ private __rozieFirstUpdateDone = false;
164168
`;
165169
}
166170

171+
pdfjsLib: any = null;
172+
167173
instance: any = null;
168174

169175
containerEl: any = null;
@@ -176,6 +182,8 @@ private __rozieFirstUpdateDone = false;
176182

177183
suppressScroll = false;
178184

185+
cancelled = false;
186+
179187
buildSource = () => {
180188
let cfg: any = null;
181189
cfg = {
@@ -197,6 +205,7 @@ private __rozieFirstUpdateDone = false;
197205
cfg.data = src;
198206
}
199207
if (this.password != null) cfg.password = this.password;
208+
if (this.standardFontDataUrl) cfg.standardFontDataUrl = this.standardFontDataUrl;
200209
return cfg;
201210
};
202211

@@ -230,7 +239,7 @@ private __rozieFirstUpdateDone = false;
230239
const tl = document.createElement('div');
231240
tl.className = 'textLayer';
232241
pageDiv.appendChild(tl);
233-
const layer = new pdfjsLib.TextLayer({
242+
const layer = new this.pdfjsLib.TextLayer({
234243
textContentSource: page.streamTextContent(),
235244
container: tl,
236245
viewport
@@ -314,6 +323,7 @@ private __rozieFirstUpdateDone = false;
314323
};
315324

316325
load = async () => {
326+
if (!this.pdfjsLib) return;
317327
const token = ++this.renderToken;
318328
if (this.observer) {
319329
this.observer.disconnect();
@@ -329,7 +339,7 @@ private __rozieFirstUpdateDone = false;
329339
if (this.containerEl) this.containerEl.innerHTML = '';
330340
if (!this.src) return;
331341
try {
332-
this.loadingTask = pdfjsLib.getDocument(this.buildSource());
342+
this.loadingTask = this.pdfjsLib.getDocument(this.buildSource());
333343
this.loadingTask.onPassword = (_updatePassword: any, reason: any) => {
334344
this.dispatchEvent(new CustomEvent("passwordrequest", {
335345
detail: {
@@ -440,7 +450,7 @@ private __rozieFirstUpdateDone = false;
440450
* (explicit `attribute:`) AND lowercased property name (Lit's default).
441451
*/
442452
private get $attrs(): Record<string, string> {
443-
const __skip = new Set<string>(['src', 'page', 'scale', 'rotation', 'worker-src', 'workersrc', 'render-all-pages', 'renderallpages', 'text-layer', 'textlayer', 'password', 'options']);
453+
const __skip = new Set<string>(['src', 'page', 'scale', 'rotation', 'worker-src', 'workersrc', 'standard-font-data-url', 'standardfontdataurl', 'render-all-pages', 'renderallpages', 'text-layer', 'textlayer', 'password', 'options']);
444454
const out: Record<string, string> = {};
445455
for (const a of Array.from(this.attributes)) {
446456
if (__skip.has(a.name)) continue;

packages/ui/pdf/packages/react/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export function Demo() {
4242
| `scale` | `Number` | `1` | | |
4343
| `rotation` | `Number` | `0` | | |
4444
| `workerSrc` | `String` | `"https://cdn.jsdelivr.net/npm/pdfjs-dist@6.0.227/build/pdf.worker.min.mjs"` | | |
45+
| `standardFontDataUrl` | `String` | `"https://cdn.jsdelivr.net/npm/pdfjs-dist@6.0.227/standard_fonts/"` | | |
4546
| `renderAllPages` | `Boolean` | `false` | | |
4647
| `textLayer` | `Boolean` | `true` | | |
4748
| `password` | `unknown` | `undefined` | | |

packages/ui/pdf/packages/react/src/PdfViewer.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export interface PdfViewerProps {
1010
scale?: number;
1111
rotation?: number;
1212
workerSrc?: string;
13+
standardFontDataUrl?: string;
1314
renderAllPages?: boolean;
1415
textLayer?: boolean;
1516
password?: unknown;

packages/ui/pdf/packages/react/src/PdfViewer.tsx

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,6 @@ import { forwardRef, useCallback, useEffect, useImperativeHandle, useRef, useSta
22
import { clsx, useControllableState } from '@rozie/runtime-react';
33
import './PdfViewer.css';
44
import './PdfViewer.global.css';
5-
import * as pdfjsLib from 'pdfjs-dist';
6-
7-
// null-lets so the bundled-leaf typeNeutralize pass annotates them `any`:
8-
// `instance` is the PDFDocumentProxy (whose strict types the loosely-typed props
9-
// don't satisfy — routing the render chain through `any` is the maplibre
10-
// mapOptions idiom), containerEl is the scroll host, observer is the
11-
// continuous-mode scroll spy.
125

136
interface PdfViewerProps {
147
src?: unknown;
@@ -18,6 +11,7 @@ interface PdfViewerProps {
1811
scale?: number;
1912
rotation?: number;
2013
workerSrc?: string;
14+
standardFontDataUrl?: string;
2115
renderAllPages?: boolean;
2216
textLayer?: boolean;
2317
password?: unknown;
@@ -46,23 +40,26 @@ export interface PdfViewerHandle {
4640

4741
const PdfViewer = forwardRef<PdfViewerHandle, PdfViewerProps>(function PdfViewer(_props: PdfViewerProps, ref): JSX.Element {
4842
const __defaultOptions = useState(() => (() => ({}))())[0];
49-
const props: Omit<PdfViewerProps, 'src' | 'scale' | 'rotation' | 'workerSrc' | 'renderAllPages' | 'textLayer' | 'password' | 'options'> & { src: unknown; scale: number; rotation: number; workerSrc: string; renderAllPages: boolean; textLayer: boolean; password: unknown; options: Record<string, any> } = {
43+
const props: Omit<PdfViewerProps, 'src' | 'scale' | 'rotation' | 'workerSrc' | 'standardFontDataUrl' | 'renderAllPages' | 'textLayer' | 'password' | 'options'> & { src: unknown; scale: number; rotation: number; workerSrc: string; standardFontDataUrl: string; renderAllPages: boolean; textLayer: boolean; password: unknown; options: Record<string, any> } = {
5044
..._props,
5145
src: _props.src ?? undefined,
5246
scale: _props.scale ?? 1,
5347
rotation: _props.rotation ?? 0,
5448
workerSrc: _props.workerSrc ?? 'https://cdn.jsdelivr.net/npm/pdfjs-dist@6.0.227/build/pdf.worker.min.mjs',
49+
standardFontDataUrl: _props.standardFontDataUrl ?? 'https://cdn.jsdelivr.net/npm/pdfjs-dist@6.0.227/standard_fonts/',
5550
renderAllPages: _props.renderAllPages ?? false,
5651
textLayer: _props.textLayer ?? true,
5752
password: _props.password ?? undefined,
5853
options: _props.options ?? __defaultOptions,
5954
};
6055
const attrs: Record<string, unknown> = (() => {
61-
const { src, page, scale, rotation, workerSrc, renderAllPages, textLayer, password, options, defaultValue, onPageChange, defaultPage, ...rest } = _props as PdfViewerProps & Record<string, unknown>;
62-
void src; void page; void scale; void rotation; void workerSrc; void renderAllPages; void textLayer; void password; void options; void defaultValue; void onPageChange; void defaultPage;
56+
const { src, page, scale, rotation, workerSrc, standardFontDataUrl, renderAllPages, textLayer, password, options, defaultValue, onPageChange, defaultPage, ...rest } = _props as PdfViewerProps & Record<string, unknown>;
57+
void src; void page; void scale; void rotation; void workerSrc; void standardFontDataUrl; void renderAllPages; void textLayer; void password; void options; void defaultValue; void onPageChange; void defaultPage;
6358
return rest;
6459
})();
60+
const cancelled = useRef(false);
6561
const containerEl = useRef<any>(null);
62+
const pdfjsLib = useRef<any>(null);
6663
const renderToken = useRef(0);
6764
const observer = useRef<any>(null);
6865
const loadingTask = useRef<any>(null);
@@ -118,6 +115,7 @@ const PdfViewer = forwardRef<PdfViewerHandle, PdfViewerProps>(function PdfViewer
118115
cfg.data = src;
119116
}
120117
if (props.password != null) cfg.password = props.password;
118+
if (props.standardFontDataUrl) cfg.standardFontDataUrl = props.standardFontDataUrl;
121119
return cfg;
122120
}
123121
async function renderPage(pdf: any, pageNum: any, container: any) {
@@ -150,7 +148,7 @@ const PdfViewer = forwardRef<PdfViewerHandle, PdfViewerProps>(function PdfViewer
150148
const tl = document.createElement('div');
151149
tl.className = 'textLayer';
152150
pageDiv.appendChild(tl);
153-
const layer = new pdfjsLib.TextLayer({
151+
const layer = new pdfjsLib.current.TextLayer({
154152
textContentSource: page.streamTextContent(),
155153
container: tl,
156154
viewport
@@ -223,6 +221,7 @@ const PdfViewer = forwardRef<PdfViewerHandle, PdfViewerProps>(function PdfViewer
223221
}
224222
const { onError: _rozieProp_onError, onLoad: _rozieProp_onLoad, onPasswordrequest: _rozieProp_onPasswordrequest } = props;
225223
const load = useCallback(async () => {
224+
if (!pdfjsLib.current) return;
226225
const token = ++renderToken.current;
227226
if (observer.current) {
228227
observer.current.disconnect();
@@ -238,7 +237,7 @@ const PdfViewer = forwardRef<PdfViewerHandle, PdfViewerProps>(function PdfViewer
238237
if (containerEl.current) containerEl.current.innerHTML = '';
239238
if (!props.src) return;
240239
try {
241-
loadingTask.current = pdfjsLib.getDocument(buildSource());
240+
loadingTask.current = pdfjsLib.current.getDocument(buildSource());
242241
loadingTask.current.onPassword = (_updatePassword: any, reason: any) => {
243242
_rozieProp_onPasswordrequest && _rozieProp_onPasswordrequest({
244243
reason
@@ -314,13 +313,21 @@ const PdfViewer = forwardRef<PdfViewerHandle, PdfViewerProps>(function PdfViewer
314313
}
315314

316315
useEffect(() => {
317-
pdfjsLib.GlobalWorkerOptions.workerSrc = _workerSrcRef.current;
316+
cancelled.current = false;
318317
containerEl.current = viewerEl.current;
319318
setCurrent(Math.max(1, _pageRef.current));
320319
setZoom(_scaleRef.current);
321320
setRot(_rotationRef.current);
322-
load();
321+
// lazy-load the engine (SSR-safe + code-split), then configure the worker and
322+
// load the document.
323+
import('pdfjs-dist').then((mod: any) => {
324+
if (cancelled.current) return;
325+
pdfjsLib.current = mod;
326+
pdfjsLib.current.GlobalWorkerOptions.workerSrc = _workerSrcRef.current;
327+
load();
328+
});
323329
return () => {
330+
cancelled.current = true;
324331
renderToken.current++;
325332
if (observer.current) {
326333
observer.current.disconnect();
@@ -344,7 +351,7 @@ const PdfViewer = forwardRef<PdfViewerHandle, PdfViewerProps>(function PdfViewer
344351
useEffect(() => {
345352
if (_watch2First.current) { _watch2First.current = false; return; }
346353
const v = props.workerSrc;
347-
if (v) pdfjsLib.GlobalWorkerOptions.workerSrc = v;
354+
if (pdfjsLib.current && v) pdfjsLib.current.GlobalWorkerOptions.workerSrc = v;
348355
}, [props.workerSrc]);
349356
useEffect(() => {
350357
if (_watch3First.current) { _watch3First.current = false; return; }

packages/ui/pdf/packages/solid/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export function Demo() {
4242
| `scale` | `Number` | `1` | | |
4343
| `rotation` | `Number` | `0` | | |
4444
| `workerSrc` | `String` | `"https://cdn.jsdelivr.net/npm/pdfjs-dist@6.0.227/build/pdf.worker.min.mjs"` | | |
45+
| `standardFontDataUrl` | `String` | `"https://cdn.jsdelivr.net/npm/pdfjs-dist@6.0.227/standard_fonts/"` | | |
4546
| `renderAllPages` | `Boolean` | `false` | | |
4647
| `textLayer` | `Boolean` | `true` | | |
4748
| `password` | `unknown` | `undefined` | | |

0 commit comments

Comments
 (0)