refactor: load pdf worker from local using fetch method

This commit is contained in:
prafull-opensignlabs
2024-06-16 01:01:05 +05:30
committed by GitHub
parent de120dae39
commit de62052453
+15 -1
View File
@@ -31,7 +31,21 @@ const ManageSign = lazy(() => import("./pages/Managesign"));
const GenerateToken = lazy(() => import("./pages/GenerateToken"));
const Webhook = lazy(() => import("./pages/Webhook"));
pdfjs.GlobalWorkerOptions.workerSrc = `//cdnjs.cloudflare.com/ajax/libs/pdf.js/${pdfjs.version}/pdf.worker.min.mjs`;
const path = new URL(
"pdfjs-dist/legacy/build/pdf.worker.min.mjs",
import.meta.url
).toString();
fetch(path)
.then((fetchResponse) => {
return fetchResponse.text();
})
.then((code) => {
const codeBlob = new Blob([code], { type: "text/javascript" });
const workerURL = URL.createObjectURL(codeBlob);
pdfjs.GlobalWorkerOptions.workerSrc = workerURL;
})
.catch((err) => console.log("err in load pdf worker", err));
const AppLoader = () => {
return (
<div className="flex justify-center items-center h-[100vh]">