Closed jiadesen closed 11 months ago
That's ok. I used cdn url and that worked. It broke in playwright tests so for that I used the assets url.
This seems to be angular related issue.
On Wed, 10 Jul 2024, 00:03 JHarrisGTI, @.***> wrote:
@MikeDabrowski https://github.com/MikeDabrowski I have not seen such an error. ☹️ If pdf.worker.min.mjs is in your assets folder, I don't know why pdf.js would be unable to see it. Sorry I can't be more help.
— Reply to this email directly, view it on GitHub https://github.com/mozilla/pdf.js/issues/17245#issuecomment-2218807083, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEICW36RQJNZFS6V7ONNOZ3ZLRM23AVCNFSM6AAAAAA7EGAPAKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMJYHAYDOMBYGM . You are receiving this because you were mentioned.Message ID: <mozilla/pdf .@.***>
@JHarrisGTI
pdfJsLib.GlobalWorkerOptions.workerSrc = 'assets/pdf.worker.min.mjs';
I did that too, my deployed assets contain the worker file but the src like that cant use it.
Error: Setting up fake worker failed: "Failed to resolve module specifier 'assets/pdf.worker.min.mjs'"
Have you seen such error?
Even if I put the full url to this file - the error is
Failed to fetch dynamically imported module
This worked for me, using angular@18.1.3 & pdfjs-dist@4.5.136
I get vite's warning when ng serve
is running
11:21:03 [vite] warning:
.../.angular/cache/18.1.3/vite/deps/pdfjs-dist.js
11783| const worker = yield import(
11784| /*webpackIgnore: true*/
11785| this.workerSrc
| ^^^^^^^^^^^^^^
11786| );
11787| return worker.WorkerMessageHandler;
The above dynamic import cannot be analyzed by Vite.
See https://github.com/rollup/plugins/tree/master/packages/dynamic-import-vars#limitations for supported dynamic import formats. If this is intended to be left as-is, you can use the /* @vite-ignore */ comment inside the import() call to suppress this warning.
Plugin: vite:import-analysis
File: .../.angular/cache/18.1.3/vite/deps/pdfjs-dist.js?v=0c2fc72a
but all work fine
import {getDocument, GlobalWorkerOptions, PDFPageProxy} from "pdfjs-dist";
private async tryToGetPdf(pdfFile: File) {
GlobalWorkerOptions.workerSrc = 'assets/pdf-worker/build/pdf.worker.min.mjs';
const arrayBuffer = await pdfFile.arrayBuffer();
const loadingTask = getDocument(arrayBuffer);
....
}
I still face the excact same issues as described above and in many other threads. My API version and worker version doesnt match, but whenver i would upgrade or downgrade either the worker or the pdfjs-dist then it is still not resolved.
I have tried to follow along on multiple suggestions and tried countless versions but I still cant seem to get it to work.
This is something that I am trying to do in React, NextJs and TypeScript.
Is there a posibility to get someone to help or perhaps pairprogram it with me since i feel like it is a lost cause...?
Attach (recommended) or Link to PDF file here: any
Configuration: