stellR42 / vue3-pdf-app

Vue 3 PDF viewer based on Mozilla's PDFJS
MIT License
82 stars 28 forks source link

emit features doesn't work properly #2

Closed serile closed 1 year ago

serile commented 1 year 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.

Configuration:

Steps to reproduce the problem:

  1. emits "open", "pages-rendered" are not work when I transfer pdf prop to vue3-pdf-app component initially. It's only works by opening to click the open button in the secondary toolbar.

  2. there are some warning and error logs on the console.

    • "could not parse arguments for #print_progress_percent. argument {{ progress }} for #print_progress_percent is undefined."
    • "[DOM] Password field is not contained in a form"
    • "loading-icon.2cb588dc.svg is 404 (Not Found)". this file has loaded relative path.

My simple code is here

PdfViewer.vue

<template>
    <div>
        <VuePdfApp
            :pdf="url"
            :title="true"
            :page-number="1"
            theme="light"
            @pages-rendered="renderHandler"
        />
    </div>
</template>
<script setup>
import 'vue3-pdf-app/dist/icons/main.css'
import VuePdfApp from 'vue3-pdf-app'

defineProps(['url'])

function renderHandler(pdfApp) {
    console.log('pdfApp', pdfApp)

    pdfApp.eventBus.on('pagechanging', event => console.log(event))
}
</script>

Thank you.

Ajitweb commented 1 year ago

Thanks @stellR42 for this previewer. I tried several others - before settling on your package.

It seems that the @open and @pages-rendered are fired - only if the document is opened through the open icon of the previewer. It does not fire when :pdf is changed in the code (that is reactively).

I needed to change the page scaling to page-width every time, the user opens a document (via a reactive :pdf) which I thought can be accomplised by the @pages-rendered event. But it does not fire.

@stellR42 - can u pls look into this.

Thanks.

stellR42 commented 1 year ago

The open event is specifically meant to trigger when the Open dialog is used. I will update it to add the pages-rendered event when the file is loaded.

Ajitweb commented 1 year ago

Thanks @stellR42 . Its working !

serile commented 1 year ago

It works very well! Thanks @stellR42

W113N23 commented 1 year ago

@serile I also encountered this problem,Can you tell me how to solve it, thank you