使用vue-pdf预览pdf和解决pdf电子签章显示问题
第一步:npm install vue-pdf
第二步页面使用vue-pdf
<template><div class="pdf1"><Pdf v-for="i in numPages" :key="i" :src="src" :page="i" /></div>
</template><script>
import Pdf from "vue-pdf";export default {components: {Pdf},data() {return {numPages: undefined,src: "",fileUrl: `${window.location.origin}/test1.pdf`};},mounted() {},created() {this.getPdfs();},mounted() {},methods: {getPdfs() {let CMAP_URL = "https://unpkg.com/pdfjs-dist@2.0.943/cmaps/";this.src = Pdf.createLoadingTask({url: this.fileUrl, cMapUrl: CMAP_URL,cMapPacked: true});this.src.promise.then(pdf => {this.numPages = pdf.numPages;});}}
};
第三步pdf预览电子签章显示问题-解决办法
步骤一: 在node_modules/pdfjs-dist/build/pdf.worker.js注释掉一行代码
if (data.fieldType === "Sig") {data.fieldValue = null;
}
步骤二:在node_modules/pdfjs-dist/es5/build/pdf.worker.js注释掉一行代码
if (data.fieldType === "Sig") {data.fieldValue = null;}