1.0.2 • Published 11 months ago

@neosjs/pdf-viewer v1.0.2

Weekly downloads
-
License
MIT
Repository
-
Last release
11 months ago

@neosjs/pdf-viewer

NPM Version Npm Week Downloads Npm Month Downloads License PDF Viewer

基于Mozilla的PDFJS封装的Vue3 PDF预览器

基本功能:

  • 缩放
  • 打开文件
  • 打印
  • 下载
  • 旋转
  • 文本选择
  • 搜索

安装

pnpm add @neosjs/pdf-viewer

npm install @neosjs/pdf-viewer --save

yarn add @neosjs/pdf-viewer

使用

<template>
  <PdfViewer
    :pdf="pdf"
    :page-number="1"
    :config="config"
    file-name="PDF的名字"
    style="position: relative"
  />
</template>

<script lang="ts">
import PdfViewer from '@neosjs/pdf-viewer'
import '@neosjs/pdf-viewer/dist/index.css'

const pdf = ref('xxxxxx.pdf') // PDF文件的URL
const theme = ref('dark') // 主题颜色
const config = ref({
  secondaryToolbar: false, // 是否显示次要工具栏
  sidebar: false, // 是否显示侧边栏
  toolbar: {
    toolbarViewerLeft: { // 左侧工具栏, 如果不需要显示,可以设置为false
      findbar: true, // 搜索
      previous: true, // 上一页
      next: true, // 下一页
      pageNumber: true // 页码
    },
    toolbarViewerMiddle: { // 中间工具栏, 如果不需要显示,可以设置为false
      zoomOut: true, // 缩小
      zoomIn: true, // 放大
      scaleSelectContainer: false // 缩放选择
    },
    toolbarViewerRight: { // 右侧工具栏, 如果不需要显示,可以设置为false
      presentationMode: true, // 演示模式
      openFile: true, // 打开文件
      print: true, // 打印
      download: true, // 下载
    }
  }
})
</script>

Props

名称类型默认值说明
pdfstring-PDF文件的URL
page-numbernumber1PDF的初试页码
page-scalenumber1PDF的缩放值
configobject-PDF的配置
file-namestring-PDF的名字
themestringdark主题颜色

Events

名称说明
after-createdPDF创建完成
openPDF打开完成
pages-renderedPDF渲染完成
update-theme主题颜色更新

License

MIT License © 2021-PRESENT NeosJS

1.0.2

11 months ago

1.0.1

12 months ago

1.0.0

12 months ago