Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@sunsetglow/vue-pdf-viewer

Package Overview
Dependencies
Maintainers
0
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sunsetglow/vue-pdf-viewer

vue pdf viewer

  • 0.0.6
  • npm
  • Socket score

Version published
Weekly downloads
11
decreased by-90.91%
Maintainers
0
Weekly downloads
 
Created
Source

@sunsetglow/vue-pdf-viewer

用来预览 pdf 文件,开箱即用,无需多余的开发,操作简单,支持 vue3 vite,

installation

pnpm i @sunsetglow/vue-pdf-viewer

yarn add @sunsetglow/vue-pdf-viewer

npm i @sunsetglow/vue-pdf-viewer

example

<template>
  <div id="pdf-container"></div>
</template>
<script lang="ts" setup>
import { initPdfView } from "@sunsetglow/vue-pdf-viewer";
import "@sunsetglow/vue-pdf-viewer/dist/style.css";
import { onMounted } from "vue";
/**
 * pdf.worker.min.mjs 文件在@sunsetglow/vue-pdf-viewer/libs 文件夹里,copy 到自己项目的静态资源里
 */
const loading = ref(false);
const pdfPath = new URL("/src/assets/pdf.worker.min.mjs", import.meta.url).href;
onMounted(() => {
  loading.value = true;
  initPdfView(document.querySelector("#pdf-container") as HTMLElement, {
    loadFileUrl: `https:xxx.pdf`, //文件路径
    pdfPath: pdfPath, // pdf.js 里需要指定的文件路径
    loading: (load: boolean) => {
      loading.value = load;
      //加载完成会返回 false
    },
    pdfOption: {
      scale: true, //缩放
      pdfImageView: true, //pdf 是否可以单片点击预览
      page: true, //分页查看
      navShow: true, //左侧导航
      navigationShow: false, // 左侧导航是否开启
      pdfViewResize: true, // 是否开启resize 函数 确保pdf 根据可视窗口缩放大小
      toolShow: true, // 是否开启顶部导航
      download: true, //下载
      clearScale: 1.5, // 清晰度 默认1.5 感觉不清晰调大 ,当然清晰度越高pdf生成性能有影响
      fileName: "preview.pdf", // pdf 下载文件名称
    },
  });
});
</script>

<style scoped>
#pdf-container {
  width: 100%;
  padding: 0px;
  height: 100%;
}
</style>

参数说明

参数名称内容 说明
loadFileUrl文件地址(必选)
pdfPathpdf.js 里所需的 pdf.worker.min.mjs 指向地址(必选)
pdfOptionpdf 的配置选项 (可选)
loadingpdf 加载完成执行函数 (可选)

欢迎大家的使用

  • 如果帮助到你,帮忙点个 starred ,有任何改进可直接提 issue 或者私信邮箱 wyaoting999@163.com

  • github 仓库地址 sunsetglow-vue-pdf-viewer

致谢

  • 此库基于 pdf.js 进行二次封装感谢大佬的开源贡献精神

Keywords

FAQs

Package last updated on 05 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc