sandanat / vue-pdf-app

VUEjs v2 PDF viewer based on Mozilla's PDFJS
MIT License
223 stars 103 forks source link

using 2 vue-pdf-apps on the same page is impossible #100

Open childonline opened 2 years ago

childonline commented 2 years ago

Please provide a working example with a bug (git repo, codesandbox, source code at least, etc). It takes a lot of time to set up environment to confirm an issue. So I will resolve issues faster. I've added 2 identical vue-pdf-apps in your ThemeToggling example, as you can see the second pdf doesn't load, I suspect this is because of the hardcoded id (vuePdfApp) in pdf-viewer.vue https://codesandbox.io/s/vue-2-vue-pdf-app-forked-5hsgcx?file=/src/views/ThemeToggling.vue

Configuration:

Steps to reproduce the problem:

Load 2 or more vue-pdf-apps on the same page, it doesn't matter if they're loading the same pdf file or not.

What is the expected behavior?

Allow different pdf files to be loaded in different vue-pdf-apps on the same page.

What went wrong?

Only one instance of the component loads a pdf file, the second, doesn't load anything.

Attachments (screenshots, links, etc)

image

denozavr commented 11 months ago

Initially the requirements were to show single pdf on the page and this component served well, thanks for that. With the course of time the customer decided that 2 pdf-previews should be shown on 1 page and I found out that this cannot be done (at least for now), since the last loaded document overwrite the first one (and 1st preview become just blank).

For someone who encountered the same issue, I solved this problem by directly using the PDF.js with <iframe>. For customization of the toolbar I used the example from this article

As you can see from the screenshot below both pdf-previews display different documents correctly (and presentation + download functionality works well for each of the document). The documents which displayed are downloaded from Azure Blob Storage. Hope this info will be helpful for someone

image