pdfjs 展示电子签章及中文丢失解决方案
展示电子签章
修改pdfjs-dist/build/pdf.work.js
的源码,全局搜索AnnotationFlag.HIDDEN:
if(data.fieldType==='Sig') {
warn('unimplemented annotation type: Widget signature');
// 注释下面这行代码
this.setFlags(AnnotationFlag.HIDDEN);
}
中文丢失
复制node_modules/pdfjs-dist/cmaps
到statics目录,vue中渲染pdf修改为
const cMapUrl = '/static/cmaps/';
let vm = this
PDFJS.getDocument({url:vm.pdfurl,cMapUrl:cMapUrl,cMapPacked:true}).then(function (pdfDoc_) { // 初始化pdf
vm.pdfDoc = pdfDoc_
vm.page_count = vm.pdfDoc.numPages
vm.renderPage(vm.pageNum)
})
最新评论