vue 预览PDF(文件流格式)

安装:

1
npm install vue-pdf-signature

引入:

1
2
3
import pdf from 'vue-pdf-signature';
 
import CMapReaderFactory from 'vue-pdf-signature/src/CMapReaderFactory';<br>components: { pdf,CMapReaderFactory},

预览标签:

1
2
<!-- pdf -->
<pdf ref="pdf" :src="pdfSrc" class="pdf" style=""></pdf>

 绑定方法:

1
2
3
4
5
6
7
getPdf(row.id).then(response => {
        // console.log(response);
        const blob = new Blob([response], { type: 'application/pdf' })
        this.pdfSrc =window.URL.createObjectURL(blob)
        console.log(this.pdfSrc);
        window.open(this.pdfSrc)//新窗口打开,借用浏览器去打印
        // this.$refs.pdf.print();//这个打印调不起来,一直显示print方法找不到<br>});

 就这样吧

posted @   微凉_1993  阅读(2942)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
点击右上角即可分享
微信分享提示