question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

load pdf the second time, doesn't work

See original GitHub issue

hey,i use vue-pdf@3.3.1 in my project. and i use this code in some .vue file <pdf ref="pdf" :src="'/projects/'+ this.$store.state.projectId +'/results/050.DESeq2/ALL.pairs.pdf'" class=""></pdf> when i click the first html i can see pdf in my html. and i click the other html , i can’t see pdf in my html, it doesn’t request src… what’s wrong with my code? should i add setTimeout to load src?? i try to add setTimeout,but it doesn’t work… thanks a lot!!!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

7reactions
shreddingcommented, Aug 28, 2019

I had finally some time (or pushing reason because we want to move to production 😃 ) to investigate this.

vue-pdf (or pdf.js for that sense) uses a worker to fetch the pdf. for some weird reason very deep in the pdf.js it maintains some weird reference to the worker used for the previous fetch here:

https://github.com/mozilla/pdf.js/blob/56ae7a669099b3439b325e434fc6d981910db2c6/src/display/api.js#L1786-L1788

It can be fixed like this:

this.loadingTask = pdf.createLoadingTask(this.src)
await this.loadingTask.then((pdf) => {
    this.loadingTask._worker.destroy()
})

It is explicitly forcing the old worker to go away.

0reactions
jly61commented, Aug 23, 2022

I had finally some time (or pushing reason because we want to move to production 😃 ) to investigate this.

vue-pdf (or pdf.js for that sense) uses a worker to fetch the pdf. for some weird reason very deep in the pdf.js it maintains some weird reference to the worker used for the previous fetch here:

https://github.com/mozilla/pdf.js/blob/56ae7a669099b3439b325e434fc6d981910db2c6/src/display/api.js#L1786-L1788

It can be fixed like this:

this.loadingTask = pdf.createLoadingTask(this.src)
await this.loadingTask.then((pdf) => {
    this.loadingTask._worker.destroy()
})

It is explicitly forcing the old worker to go away.

Thanks, this worked for me

Read more comments on GitHub >

github_iconTop Results From Across the Web

Adobe Reader does not open second pdf from Explore...
The issue is that double-clicking a second PDF to open it in a new tab page doesn't do anything. The explorer window flickers...
Read more >
6 Fixes to Try When Adobe Acrobat Reader Can't Open PDF ...
6 Fixes to Try When Adobe Acrobat Reader Can't Open PDF Files on Windows · Right-click on the Windows Start button and select...
Read more >
PDF won't open? How to Fix PDF Files not Opening Error
PDF files won't open on your PC? Don't panic! This article is about how to fix issues with PDF files that are not...
Read more >
PDF reader Fails to Save Sensitive PDF Documents Due to ...
PDF reader Fails to Save Sensitive PDF Documents Due to Second Download Attempt · Open Edge Settings and more (Alt+F) · Choose Cookies...
Read more >
Having Problems with Fillable PDF Forms?
If the downloaded pdf file didn't open correctly, you may need to change the default pdf viewer for the computer. If you are...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found