react----项目实际过程中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)
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章