PDFJS研究 兼容IE 360极速

  经过我后来的研究发现,pdfjs并不支持ie10及以下,请不要被一些无良博客欺骗了!!

https://github.com/mozilla/pdf.js/wiki/Frequently-Asked-Questions#which-browsers-are-supported


下载pdf.js文件http://mozilla.github.io/pdf.js/

  1. 解压文件全部将其放置到项目web或者webapp下
  2. 使用XX\pdfjs/web/viewer.html能看到一个pdf文件就说明加载成功了
  3. 普通的使用方法其他文章也能看见,跨域问题等请看别的博客,一会推荐
  4. 此处是mongodb二进制文件流输出
  5. window.open('/XX/resources/front/js/pdfjs/web/viewer.html?file='+encodeURIComponent(fileurl));
  6. /**
         * 根据项目id查找附件-预览
         * @param
         * @return
         */
        @RequestMapping(value="/XX")
        public void XX(String proid ,HttpServletResponse resp) {
            if(proid !=null && !"".equals(proid)){
                //获取项目详情数据
                try{
                    OutputStream os = resp.getOutputStream();
                    TbAttachment atta = tbattachmentservice.selectByProId(proid);
                    if(atta != null){
                        gsMongoClient.downloadLt15M(name, atta.getId(), os);
                    }
                    
                }catch(Exception e){
                    e.printStackTrace();
                }
            }
        }

    mongodb下载文件流 

    @Override
    	public void downloadLt15M(String collName, String _id, OutputStream os) throws IOException {
    		MongoCollection<Document> collection = GetDatabase().getCollection(collName);
    		FindIterable<Document> docIter = collection.find(Filters.eq(ID, _id));
    		Binary binary = (Binary) docIter.first().get(FILE);
    		byte[] file= binary.getData();
    		BufferedOutputStream bos=new BufferedOutputStream(os);
    		bos.write(file);
    		bos.flush();
    		bos.close();
    		os.close();
    	}

    博客推荐

  7. https://blog.csdn.net/yuhaifei_123/article/details/79174057?utm_source=blogxgwz5

  8. https://blog.csdn.net/l_ai_yi/article/details/82388497

  9. https://blog.csdn.net/jianyuerensheng/article/details/79570781

  10. https://blog.csdn.net/l_ai_yi/article/details/82388497#commentBox

  11. https://www.jb51.net/article/141607.htm

最后附上ie浏览器怎么清除缓存,可以说很难找了:sessionStorage.clear()        localStorage.clear()

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值