美文网首页
html 实现动态在线预览word、excel、pdf等文件(方

html 实现动态在线预览word、excel、pdf等文件(方

作者: Marting424 | 来源:发表于2020-01-03 17:28 被阅读0次

word+excle+pdf表格在线浏览

通过iframe直接引用微软提供的方法

<iframe src='https://view.officeapps.live.com/op/view.aspx?src=http://storage.xuetangx.com/public_assets/xuetangx/PDF/1.xls' width='100%' height='100%' frameborder='1'></iframe>

在 https://view.officeapps.live.com/op/view.aspx?src= 后边添加需要预览的内容

注意:链接包含中文需要进行URL编码,并且文档必须可在Internet上公开访问

官方使用文档

pdf在线浏览

PDF.js下载地址

http://jhyt.oss-cn-shanghai.aliyuncs.com/images/1531367199089_PDFObject.js

使用方法

引入pdf.js文件

<script src="./js/PDF/PDFObject.js" type="text/javascript"></script>c

创建有个div用于展示

<div id="example1"></div>

通过js动态添加需要浏览的pdf地址

var options = {

            height: "550px",

            pdfOpenParams: {view: 'FitV', page: '0' },

            name:"mans",

            fallbackLink: "<p>您的浏览器暂不支持此pdf,请下载最新的浏览器</p>"

        };

PDFObject.embed(url, "#example1",options);

预览效果

————————————————

版权声明:本文为CSDN博主「superKM」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。

原文链接:https://blog.csdn.net/superKM/article/details/81013304

相关文章

网友评论

      本文标题:html 实现动态在线预览word、excel、pdf等文件(方

      本文链接:https://www.haomeiwen.com/subject/taftactx.html