-
-
Notifications
You must be signed in to change notification settings - Fork 131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using Worker with Vue 3 #104
Comments
Hi Tim,Actually pdfvuer already uses the webworker to download and show the pdf. However, simultaneously rendering and showing all pages of a pdf is a very memory intensive operation and that is a constraints that is coming from pdf.js directly. I am currently trying to implement a rendering mechanism so that only the visible pages of pdf is rendered and the others are deallocated. Planning to share this as a recommended example. On 20-Aug-2021 21:47, Tim Pulver ***@***.***> wrote:
I tried to use PdfVuer 2.0.1 with Vue.js 3 to display all pages of a PDF (~25 pages).
Because the loading is quite slow, it became obvious that a web worker should be used. Is there currently a way to use the web worker approach with Vue 3?
I did not find a way to load the worker library from pdfjs-dist and pass it on to the internals of PdfVuer to use the worker.
My component:
<template>
<div v-if="isLoading">
<div>Loading Manual</div>
</div>
<VuePdf
:src="pdfData"
v-for="i in numPages"
:key="i"
:id="i"
:page="i"
annotation
</VuePdf>
</template>
<script>
import VuePdf from "pdfvuer/dist/pdfvuer.common.js";
import pdfFile from "../assets/pdfs/My_PDF.pdf";
export default defineComponent({
components: { VuePdf },
data() {
return {
pdfData: undefined,
numPages: 0,
currentPage: 1,
isLoading: true,
};
},
async mounted() {
this.$nextTick(() => {
this.pdfData = VuePdf.createLoadingTask(pdfFile);
this.pdfData.then((pdf) => {
this.numPages = pdf.numPages;
this.isLoading = false;
});
});
},
});
</script>
—You are receiving this because you are subscribed to this thread.Reply to this email directly, view it on GitHub, or unsubscribe.Triage notifications on the go with GitHub Mobile for iOS or Android.
|
Hi Gaurav,
|
same issue as above, i'm on v.2.0.1 & Vue3 and seeing the same fake worker warning in console. |
I've been working on my own project and don't use pdfvuer but use the source code as inspiration. To use the web worker properly it needs to be registered to pdfjs. This needs to be done the following way:
pdfvuer doesn't do this atm. |
I tried to use PdfVuer 2.0.1 with Vue.js 3 to display all pages of a PDF (~25 pages).
Because the loading is quite slow, it became obvious that a web worker should be used. Is there currently a way to use the web worker approach with Vue 3?
I did not find a way to load the worker library from pdfjs-dist and pass it on to the internals of PdfVuer to use the worker.
My component:
The text was updated successfully, but these errors were encountered: