Closed Pavel1Uvarov closed 6 months ago
That is a very early version, consider to update to latest version.
@TaTo30 Thanks for the quick response. I've updated the version to 1.9.3 and it didn't help me. Do you have any suggestions?
Are the errors the same?
Try to use a ref
in usePDF
for reloading PDFs:
const pdfSources = [
'/example_014.pdf',
'/example_036.pdf',
'/example_041.pdf',
'/example_045.pdf',
'https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf',
]
// Setting the first (or default) PDF
const pdfSource = ref(pdfSources[0])
const pdfSourceIdx = ref(0)
const { pdf } = usePDF(pdfSource)
function nextPdf() {
pdfSourceIdx.value += 1
if (pdfSourceIdx.value >= pdfSources.length)
pdfSourceIdx.value = 0
pdfSource.value = pdfSources[pdfSourceIdx.value]
}
You can get the full example here: https://tato30.github.io/vue-pdf/examples/advanced/multiple_pdf.html
@TaTo30 Yes, the error is the same. "Try to use a ref in usePDF for reloading PDFs:" What do you mean? Can you explain, please?
I get one file from the back end. So I sent a request to my back-end with a couple of PDF files and got a response with PDF which was combined. And I have drag-and-drop and after I change the file order I sent a new request to get a new one combined PDF file and after that I got this 2 errors
@TaTo30 Also after updating the version I got a new error
:fit-parent="false" - if set false the error isn't showing
usePDF
is reactive, if you provide a ref
value on src
param the component will update the PDF automatically when the src
changes, look the example that i shared above.
@TaTo30 I see. What if before uploading PDF my ref is empty?
@TaTo30 Fixed by using not empty string in ref. But is there any way to pass emptiness so that there is no immediate request to try to receive a PDF file?
You could use undefined
instead empty string but you will probably get a type warning.
On my page, there is a PDF combiner, the essence of which is to combine several PDFs into one. Every time I change the order and send a back request, after receiving a response and reloading the PDF, I get two errors
"@tato30/vue-pdf": "^1.3.4", "vue": "^3.2.47", "vite": "^4.5.0"
Template:
Script: