Pdfvuer
A PDF viewer for Vue using Mozilla's PDF.js
Install
npm install --save vue-pdf
Example - basic
<template>
<pdf src="./static/relativity.pdf" :page=1></pdf>
</template>
<script>
import pdf from 'pdfvuer'
export default {
components: {
pdf
}
}
API
Props
:src String / Object - default: ''
The url of the pdf file. src
may also be a string|TypedArray|DocumentInitParameters|PDFDataRangeTransport
for more details, see PDFJS.getDocument()
.
:page Number - default: 1
The page number to display.
:rotate Number - default: 0
The page rotation in degrees, only multiple of 90 are valid.
:scale Number / String - default: 'page-width'
The scaling factor. By default, the pdf will be scaled to match the page width
with the container width.
Events
@numpages Number
The total number of pages of the pdf.
Public static methods
createLoadingTask(src)
src
: see :src
prop
This function creates a PDFJS loading task that can be used and reused as :src
property.
Public Demo
Used in production by Gratiato
Made with :heart: at IIIT Bangalore
License
MIT © Gaurav Koley, 2018