Skip to content

GabrielBuragev/vue-pdfjs-viewer

Repository files navigation

@gabrielbu/vue-pdf-viewer

Vue PDF viewer components implemented using PDFJS.

Install

npm install --save @gabrielbu/vue-pdf-viewer

Demo

TBD

Usage in vue

<template>
  <div id="app" style="height:100vh;width:100vw; position:fixed;">
    <PDFView :src.sync="src" ref="pdfView" fileName="order" :scale.sync="scale">
      <template slot="right-toolbox"></template>
      <!-- Add more buttons/features on the right side of the toolbar -->
      <template slot="left-toolbox"></template>
      <!-- Add more buttons/features on the left side of the toolbar -->
      <template slot="error"></template>
      <!-- Change the error message design -->
      <template slot="loading"></template>
    </PDFView>
  </div>
</template>
<script>
import {PDFView} from '@gabrielbu/vue-pdf-viewer';
export default {
  components:{
  // ...
    PDFView
  },
  data(){
    return {
      scale: "1.25"
    }
  }
}
</script>

API

Props

:src String / Object - default: null

src accepts the following values:

for more details see PDFJS.getDocument().

:toolbarVisible Boolean - default: true

Toggle toolbar visibility.

:downloadFeatureVisible Boolean - default: true

Toggle download button feature visibility.

:sidebarFeatureVisible Boolean - default: true

Toggle sidebar (page navigation bar) visibility.

:dropzoneFeatureVisible Boolean - default: true

Enable/disable the dropzone(drag-n-drop PDF files) feature.

:scale String - default: "1.25"

Set the initial scale of the viewer. You can use it with :scale.sync for enabling two-way data binding.

:fileName String - default: "{Date.now()}.pdf"

Name of the file used when download function is triggered.