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
/* Copyright 2021 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
"use strict";
import * as pdfjs from "pdfjs-dist/legacy/build/pdf";
// @see https://github.com/vitejs/vite/issues/13680#issuecomment-1819274694
import PdfjsWorkerUrl from 'pdfjs-dist/legacy/build/pdf.worker?worker&url'
const js = `import ${JSON.stringify(new URL(PdfjsWorkerUrl, import.meta.url))}`
const blob = new Blob([js], { type: "application/javascript" })
function PdfjsWorker(options) {
const objURL = URL.createObjectURL(blob)
const worker = new Worker(objURL, { type: "module", name: options?.name })
worker.addEventListener("error", (e) => {
URL.revokeObjectURL(objURL)
})
return worker;
}
if (typeof window !== "undefined" && "Worker" in window) {
pdfjs.GlobalWorkerOptions.workerPort = new PdfjsWorker();
}
export default pdfjs;
This discussion was converted from issue #18101 on May 16, 2024 07:23.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello !
After reading problem #16651 I saw that PDFJS supports recent browsers (chrome 92+). For the project I'm working on, my application must support browsers from chrome 87 onwards. I tried installing polyfill (https://github.com/babel/babel-polyfills/tree/main/packages/babel-plugin-polyfill-es-shims) but it didn't change anything. Has anyone had the same problem as me?
Here is the configuration:
Thanks !
My entry point for pdf js in my application:
Beta Was this translation helpful? Give feedback.
All reactions