pdf.js实现

springboot项目

resources/js/pdf/web/viewer.html是要被访问到的,不能被过滤器过滤。

1、前端页面

$('#proBase').click(function () {

var curWwwPath=window.document.location.href;

var pathName=window.document.location.pathname;

var pos=curWwwPath.indexOf(pathName);

var localhostPath=curWwwPath.substring(0,pos);

window.open(localhostPath+"/resources/js/pdf/web/viewer.html?file="+propertyBaseUrl);

})

其中localhostPath+"/resources/js/pdf/web/viewer.html是获取项目中pdf.js的模板;

file=后面是pdf文件url路径;

1、后端:将pdf.js文件导入到项目中,就可以完成。

猜你喜欢

转载自www.cnblogs.com/lazyli/p/12901498.html