Open CHETANECINFOSOLUTIONS opened 10 months ago
Hi @CHETANECINFOSOLUTIONS
<script>
import PdfViewer from 'svelte-pdf';
</script>
<PdfViewer url='https://raw.githubusercontent.com/vinodnimbalkar/svelte-pdf/369db2f9edbf5ab8c87184193e1404340729bb3a/public/sample.pdf' />
Please check this: https://stackblitz.com/edit/sveltejs-kit-template-default-pjuhkj
Thank you for replying. I have tried this way also still returns same error.
Has anyone got this working in sveltekit? as of April 2024?
Has anyone got this working in sveltekit? as of April 2024?
you can try using this library, it works. https://pdfjs.express/documentation/get-started/svelte
Has anyone got this working in sveltekit? as of April 2024?
I have it working on sveltekit !
Has anyone got this working in sveltekit? as of April 2024?
I have it working on sveltekit !
Have you got a working repo I can take a look at?
Has anyone got this working in sveltekit? as of April 2024?
I have it working on sveltekit !
Have you got a working repo I can take a look at?
Regrettably not, but if you want you can show me your implementation and I can help you with it
Has anyone got this working in sveltekit? as of April 2024?
I have it working on sveltekit !
Have you got a working repo I can take a look at?
Regrettably not, but if you want you can show me your implementation and I can help you with it
Unless I'm missing something there's not much implementation to talk about, so let's assume the implementation at the top (initial post on this issue). Or the one in the docs:
<script>
import PdfViewer from 'svelte-pdf';
</script>
<PdfViewer url='./sample.pdf' />
I also get the same error:
This document requires a password: Setting up fake worker failed: "Cannot load script at: http://localhost:5173/node_modules/.vite/deps/pdfjs-dist/build/pdf.worker.js".
It seems that it goes in here: https://github.com/vinodnimbalkar/svelte-pdf/blob/master/src/lib/PdfViewer.svelte#L189
But I guess that this has to do with the installation.
In my project, the pdfjs-dist/
directory is located in the root level of node_modules/
instead of in node_modules/.vite/
directory as the error reports. Additionally, upon npm run build
I get this warning:
Using @sveltejs/adapter-vercel Warning: The following modules failed to locate dependencies that may (or may not) be required for your app to work: node_modules/pdfjs-dist/build/pdf.mjs
- canvas ✔ done ✓ built in 2.57s
My code
it shows this error