Skip to content

Commit 3f0ead5

Browse files
committed
add website #andy
1 parent bd042e6 commit 3f0ead5

File tree

2 files changed

+13
-16
lines changed

2 files changed

+13
-16
lines changed

.idea/workspace.xml

+2-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

website/src/components/PdfViewer.js

+11-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
import React, { useEffect, useRef, useState } from 'react';
2-
import * as pdfjsLib from 'pdfjs-dist';
3-
import { GlobalWorkerOptions } from 'pdfjs-dist';
4-
5-
// Set the worker path for PDF.js
6-
GlobalWorkerOptions.workerSrc = new URL(
7-
'pdfjs-dist/build/pdf.worker.min.mjs',
8-
import.meta.url
9-
).toString();
2+
let pdfjsLib, GlobalWorkerOptions;
3+
4+
5+
if (typeof window !== 'undefined') {
6+
pdfjsLib = require('pdfjs-dist');
7+
GlobalWorkerOptions = pdfjsLib.GlobalWorkerOptions;
8+
GlobalWorkerOptions.workerSrc = new URL(
9+
'pdfjs-dist/build/pdf.worker.min.mjs',
10+
import.meta.url
11+
).toString();
12+
}
1013

1114
const PdfViewer = ({ pdfUrl, scale }) => {
1215
const containerRef = useRef(null); // Reference to the scroll container

0 commit comments

Comments
 (0)