Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I get the total number of pages in a PDF #66

Closed
time202051 opened this issue Aug 3, 2022 · 2 comments
Closed

How do I get the total number of pages in a PDF #66

time202051 opened this issue Aug 3, 2022 · 2 comments

Comments

@time202051
Copy link

How do I get the total number of pages in a PDF

@bogdan12893
Copy link

bogdan12893 commented Aug 3, 2022

They have an example in the docs 😁 @time202051
Hope this helps!

<template>
    <div class="test-pdf flex flex-col">
        <h1 class="text-lg font-bold mb-3">Test PDF</h1>
        <div v-if="isLoading">Loading pages...</div>
        <div v-else>Total pages {{pageCount}}</div>
        <client-only>
            <div class="pdf-wrapper">
                <VuePdfEmbed class="pdf" ref="pdfRef" source="random.pdf" @rendered="handleDocumentRender"></VuePdfEmbed>
            </div>
        </client-only>
    </div>
</template>

<script>
export default {
  name: 'TestPDF',

  data () {
    return {
      pageCount: 1,
      isLoading: true
    }
  },

  methods: {
    handleDocumentRender () {
      this.isLoading = false
      this.pageCount = this.$refs.pdfRef.pageCount
    }
  }

}
</script>

@hrynko
Copy link
Owner

hrynko commented Aug 3, 2022

@bogdan12893 thanks for your comment!

Another option would be to use the loaded event value (there will be a numPages property inside)

@hrynko hrynko closed this as completed Aug 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants