DingRui12138 / vue-pdf-viewer

MIT License
17 stars 11 forks source link

After load the viewer displays the page thumnail but not the page on the right #17

Open jjakob666 opened 2 months ago

jjakob666 commented 2 months ago

After load the viewer displays the page thumnail but not the page. If I resize the browser the page then displays. it seems to be a resize issue.

I added this code after render and it resolved the issue:


handlePdfRendered() {
      console.log('handlePdfRendered() finished rendering');
      //workaround for not displaying the page on the right until a resize happens in the browser
      window.dispatchEvent(new Event('resize'));
    },
alitons commented 1 month ago

I had this problem. I used a timeout when starting the preview.

vuejs 3

<template>
    <div class="col-12 mb-3" v-if="initialized">
        <PDFViewer
            :source="route('document.contract', 18)"
        />
    </div>
</template>
<script setup>
import PDFViewer from 'pdf-viewer-vue'
const initialized = ref(false)
onMounted(() => {
    setTimeout(() => {
        initialized.value = true
    }, 500)
})
</script>