1.下载pdf文件

因为pdf文件是传到oss上的,地址是下载地址,所可以使用a标签下载,但不能使用iframe等方法预览

<el-button class="download" v-if="list&&list.length>0" @click="downloadFile(fileList)" type="text">下载</el-button>
downloadFile(fileList){window.location.href = fileList[0].urlthis.$message.success('下载成功!');
},

2.使用vue-pdf预览pdf文件

1.安装vue-pdf

npm install --save vue-pdf

2.使用

<template><div class="pdf"><pdf ref="pdf":src="pdfUrl":page="pageNum":rotate="pageRotate"@password="password"@progress="loadedRatio = $event"@page-loaded="pageLoaded($event)"@num-pages="pageTotalNum=$event" @error="pdfError($event)"@link-clicked="page = $event"></pdf><div class="pdf-tab"><el-button type="text" class="btn-def btn-pre" @click.stop="firstPage" :disabled="pageNum===1">首页</el-button><el-button type="text" class="btn-def btn-pre" @click.stop="prePage" :disabled="pageNum===1">上一页</el-button><el-button type="text" class="btn-def btn-next" @click.stop="nextPage" :disabled="pageNum===pageTotalNum">下一页</el-button><el-button type="text" class="btn-def btn-pre" @click.stop="lastPage" :disabled="pageNum===pageTotalNum">尾页</el-button><el-button type="text" class="btn-def" @click.stop="clock">顺时针</el-button><el-button type="text" class="btn-def" @click.stop="counterClock">逆时针</el-button><el-button type="text" class="btn-def" @click.stop="pdfPrintAll">全部打印</el-button><el-button type="text" class="btn-def" @click.stop="pdfPrint">部分打印</el-button></div><div class="pdf-page">{{pageNum}}/{{pageTotalNum}}</div><!-- <div>进度:{{loadedRatio}}</div><div>页面加载成功: {{curPageNum}}</div> --></div>
</template>
<script>
import pdf from 'vue-pdf'
export default {name: 'Pdf',components:{pdf},props: {pdfUrl: {type: String}},data(){return {pageNum:1,pageTotalNum:1,pageRotate:0,// 加载进度loadedRatio:0,curPageNum:0,}},mounted: function() {},methods: {firstPage() {this.pageNum = 1},prePage(){var p = this.pageNump = p>1?p-1:this.pageTotalNumthis.pageNum = p},nextPage(){var p = this.pageNump = p<this.pageTotalNum?p+1:1this.pageNum = p},lastPage() {this.pageNum = this.pageTotalNum},clock(){this.pageRotate += 90 },counterClock(){this.pageRotate -= 90 },password(updatePassword, reason) {updatePassword(prompt('password is "123456"'))},pageLoaded(e){this.curPageNum = e},pdfError(error){console.error(error)},pdfPrintAll(){this.$refs.pdf.print()},pdfPrint(){this.$refs.pdf.print(100,[1,2])},}
}
</script><style lang="scss" scoped>.pdf-tab {display: flex;}.pdf-page {text-align: right;}
</style>

vue 预览、下载pdf相关推荐

  1. react集成react-pdf获取文件流预览下载pdf,展示电子签章

    1.下载依赖包 代码如下(示例): npm install react-pdf 2.引入依赖包 代码如下(示例): import { Document, Page } from 'react-pdf' ...

  2. Vue预览word/pdf文件(内外网均可)

    预览word文件实现方式有 1 将文件放在前端静态文件中 实现本地预览 但前端包变得很大 多文件不适合 2 通过跳转外网链接访问 但内网无法使用 3 综合考虑 利用浏览器自带的预览pdf  将文件放在 ...

  3. vue预览word,excel,pptx,pdf文件

    vue预览word,excel,pptx,pdf文件 1.做word,excel,pptx的预览,要先确定文件路径访问是通过域名的url来预览,不可以通过IP的url来访问 先把文件路径的url进行u ...

  4. 【iframe结合pdf.js实现pdf的预览/下载及打印功能】

    iframe结合pdf.js实现pdf的预览/下载及打印 1.[下载pdf.js](http://mozilla.github.io/pdf.js/getting_started/#download) ...

  5. VUE预览PDF文件并利用pdf.js获取鼠标选中的文字和搜索,在iframe中获取选中文字,监听鼠标事件,右键菜单

    一.VUE预览PDF文件并利用pdf.js获取鼠标选中的文字和搜索 需求实现:vue实现预览pdf文件,获取到鼠标选中的文字数据.调用pdf.js自带的搜索方法实现搜索功能(后期可以调用该接口满足其他 ...

  6. java pdf文件下载_Java后台返回PDF文件预览下载

    Java后台返回PDF文件预览下载 开始的代码的系统代码为: ResponseEntity onePdf = s3Wrapper.download(contractEntity.getContract ...

  7. 钉钉小程序上传预览下载word,pdf文档等一系列问题

    钉钉小程序上传预览下载word,pdf文档等一系列问题 小程序"用完即走"的理念使得有着很好的发展市场,不仅微信小程序,支付宝,钉钉小程序等都受用户的喜爱. 刚接触了一个企业内部应 ...

  8. vue 预览并下载本地word

    vue 预览并下载本地word 需要下载 docx-preview <template><div class="docxPreview"><el-ro ...

  9. itext5预览/下载/字节流方式生成PDF

    原文链接:https://www.cnblogs.com/waft/p/15603802.html Java itext5预览/下载/字节流方式生成PDF,并设置页眉页脚,html识别,行首标点长数字 ...

  10. 微信小程序实现PDF预览功能——pdf.js(含源码解析)

    文章目录 前言 一.pdf.js 是什么? 二.使用步骤 1.下载库文件 2.使用方式 微信小程序端--使用 web-view 标签 H5 端--使用 iframe 标签(使用vue框架) 3.更改源 ...

最新文章

  1. String复习笔记
  2. Python生物信息学⑤DNA转录RNA
  3. Linux服务器优化(转)
  4. ping 用数字串代替IP地址
  5. ECSHOP发送邮件提示need rcpt command的解决方法
  6. PHP中的urlencode和urldecode
  7. 音视频技术开发周刊 | 193
  8. 每日一题(33)——用两个栈实现一个队列的功能?要求给出算法和思路
  9. webrtc服务器janus通信方法学习二
  10. [BZOJ4540][HNOI2016]序列(莫队)
  11. matlab插值与拟合例题_[转载]MATLAB插值与拟合(1)
  12. html网页表格线条设置,css怎么设置表格边框?
  13. Chrome浏览器快捷键
  14. matlab 自制闹钟程序,原生JS写的一个简单闹钟程序
  15. 豆瓣是用python开发的吗_Google、知乎、豆瓣、网易都在用Python Web开发!
  16. EFM32 LG232系列单片机干货之LEUART
  17. 苹果新版iOS疯狂致敬安卓和微信,新Mac搭载自研CPU!这届苹果开发者大会料足槽点密...
  18. 小程序+二维码(带logo图片,可直接运行)
  19. Linux C 遍历目录下的所有文件
  20. 安卓6.0权限处理在项目中的实践

热门文章

  1. 十八、Linux驱动之nor flash驱动
  2. mcjava盗版联机_使用N2N组建虚拟局域网联机游戏(我的世界 Java版)
  3. ROS入门的基本操作
  4. Delphi 7连接MySql 5.5.15
  5. c语言游戏程序ide,C语言编译器IDE
  6. Linux bridge table(brctl)
  7. nRF52840/nRF52832 低功耗的测试工程
  8. inno setup 卸载注册表_inno setup 自定义生成的卸载程序
  9. vue2实践揭秘pdf_Vue2实践揭秘
  10. 计算机职业价值观测评报告,关于职业价值观测评报告