0.1.3 • Published 4 years ago

vue-pdf-search-keyword v0.1.3

Weekly downloads
13
License
MIT
Repository
github
Last release
4 years ago

vue-pdf-search-keyword

Version 0.1.3 Search keywords in PDF. Project base on Vue.js and Pdf.js. This project has new customizations based in https://github.com/Youhandan/vue-pdf-search-preview

Step1 Install

npm install --save vue-pdf-search-keyword

Step2 Config webpack or vue.config(below is vue.config)

//vue.config.js

module.exports = {
   chainWebpack: config => {
   
    //...your configs
    
    config
      .plugin('copy')
      .tap(args => {
        args[0].push(
          {
            context: 'node_modules/vue-pdf-search-keyword/lib/',
            from: '*.umd.min.*.js',
            to: 'js/',
            toType: 'dir'
          },
          {
            from: 'node_modules/vue-pdf-search-keyword/lib/pdf.worker.js',
            to: 'pdf.worker.js',
            toType: 'file'
          },
        )
        return args
      })
  }
}

Step3 Import and register

//main.js

import PdfViewer from 'vue-pdf-search-keyword'

Vue.use(PdfViewer)

Example

<template>
  <pdf-viewer src="./compressed.tracemonkey-pldi-09.pdf"></<pdf-viewer>
</template>
 

API

PropsTypeDescription
srcstring or other(detail to see pdf.js getDocument())Pdf url
autoWidthboolean, default falseWhether to zoom pdf to container width when initial
EventsParametersDescription
on-loadednumberPdf total page number
on-searchobject: { current, total }Search keyword matched current number and total count
on-page-changenumberCurrent page number
MethodsParametersDescription
searchstringSearch keyword in pdf
searchAgainparam1:string, param2: booleanParam1 is search keyword, param2 is dicided to find pre(true) or find next(false)
cancelSearchnoneCancel search
zoomnumber/ string('auto')Number: The ratio of pdf zoom, 'auto': zoom to container width
jumpToPagenumberThe page number of pdf jumped to
0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago