react----项目实际过程中pdf.js的使用
pdf.js
PDF Reader in JavaScript
项目地址:https://gitcode.com/gh_mirrors/pd/pdf.js
免费下载资源
·
遇到的问题
1.当请求为https的请求的时候,如果返回的PDF的链接是http的链接,那么pdf.js打开的时候会报错
2.pdf.js的核心文件可以直接放到服务器下面,不用进行项目的报错输出
3.pdf.js在请求pdf完成之后,自动启用打印的功能
//viwer.html页面嵌入了内联的脚本进行执行
<script>
var interval = setInterval(function(){
if (PDFViewerApplication.pdfDocument == null) {
console.info('pdf 加载中...');
} else {
console.info('pdf 加载完成...');
window.print();
//加载完成
clearInterval(interval);
}
}, 1000);
</script>
4.正常情况下,本地开发的时候,pdf.js读取链接会报错,需要将原本代码的东西注释掉一点
5.如何将pdf的打开方式设置为这种新窗口弹出打开?
代码实现
var isWidth = window.screen.availWidth
var isHeight = window.screen.availHeight
var feature = "width="+isWidth+",
height="+isHeight+",
top=0,left=0,menubar=no,toolbar=no,location=no,scrollbars=no,status=no,
modal=no,titlebar=no,status=no";
window.open('/static/pdf/web/viewer.html?file='+encodeURIComponent(res.data.data.fileLink), 'newwindow',feature)
GitHub 加速计划 / pd / pdf.js
47.48 K
9.86 K
下载
PDF Reader in JavaScript
最近提交(Master分支:1 个月前 )
18284815
[Editor] Update the disclaimer string in the new alt-text dialog (bug 1911738) 1 个月前
fc602c65
And tweak the css in order to take into account that disclaimer can be on two (or more lines).
1 个月前
更多推荐
已为社区贡献1条内容
所有评论(0)