Skip to content

Issue with long PDF + pagination #166

Answered by hrynko
ghost asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @antoinedu06160,

Indeed, I would recommend displaying large documents paginated (page by page or within ranges). At some point some kind of lazy loading could be added to the lib, but for now you could use it as follows:

<template>
  <div v-if="pdfSource">
    <vue-pdf-embed
      v-for="page in pages"
      :key="page"
      :source="pdfSource"
      :page="page"
    />
  </div>
</template>

<script>
import VuePdfEmbed from 'vue-pdf-embed'

export default {
  components: {
    VuePdfEmbed,
  },
  data() {
    return {
      pages: [...Array(51).keys()].slice(1),
      pdfSource: null,
    }
  },
  async mounted() {
    this.pdfSource = await VuePdfEmbed.getDocument('<PDF_URL>').promise

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant
Converted from issue

This discussion was converted from issue #165 on October 05, 2023 12:15.