在线pdf、word、excel、ppt在线预览

阿里云浏览文档:https://help.aliyun.com/document_detail/162639.html?spm=a2c4g.11186623.6.567.7ee41fc4uSpkgE

vue浏览插件:https://github.com/cainsyake/vue-doc-preview/blob/master/README-CN.md

预览pdf
1. iframe
<iframe
:src="url"
ref="ifamePage"
width="100%"
frameborder="no"
border="0"
marginwidth="0"
marginheight="0"
height="100%"

<p>您的浏览器不支持iframe标签</p>
</iframe>

url:'http://cloudt-aliyun-test-vpc-pub.oss-cn-beijing.aliyuncs.com/safe/education_files/GPD20191218.pdf',

总结:
1)pdf展示的很好,
2)word、excel、ppt不支持,直接下载了

方法2
<embed :src="url" type="application/pdf" width="100%" height="100%">

方法3:
object
同上

方法4:https://pdfobject.com/

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

ie解决方案:(个人觉得也不好)
https://blog.csdn.net/qq_38975553/article/details/104261830?utm_medium=distribute.pc_relevant_download.none-task-blog-blogcommendfrombaidu-1.nonecase&depth_1-utm_source=distribute.pc_relevant_download.none-task-blog-blogcommendfrombaidu-1.nonecas

以上4种方法的缺点:不支持ie

方法5:(目前看最佳)

https://github.com/mozilla/pdf.js#online-demo

http://blog.lookpeakfans.xyz/2018/07/22/preview-pdf/

二、word、xls、ppt文件在线预览功能

<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'>

用法:打开页面https://view.officeapps.live.com/op/view.aspx?src=文件路径,即可在线预览文档。
文件路径必须为 http:// 或 https:// 形式,文档必须是 Word、Excel 或 PowerPoint 文档。

问题:资源是公共访问的

参考文档:https://segmentfault.com/a/1190000018806682

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容