您的位置 首页 html教程

详解html实现在线预览word、excel、pdf等文件的功能(附代码)

详解html实现在线预览word、excel、pdf等文件的功能(附代码)

本文讲述了html是如何实现动态在线预览word、excel、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

创建有个p用于展示

<p id="example1"></p>

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

 var options = {            height: "550px",            pdfOpenParams: {view: 'FitV', page: '0' },            name:"mans",            fallbackLink: "<p>您的浏览器暂不支持此pdf,请下载最新的浏览器</p>"        };PDFObject.embed(url, "#example1",options);

预览效果

dc80301ee9bbf46a7c53872b73158d2.png

感谢大家的阅读,希望大家有所收益。

本文转自:https://blog.csdn.net/superKM/article/details/81013304

文章来源:火云技术网

文章标题:详解html实现在线预览word、excel、pdf等文件的功能(附代码)

文章地址:https://www.pyhw.net/29627_%e8%af%a6%e8%a7%a3html%e5%ae%9e%e7%8e%b0%e5%9c%a8%e7%ba%bf%e9%a2%84%e8%a7%88word%e3%80%81excel%e3%80%81pdf%e7%ad%89%e6%96%87%e4%bb%b6%e7%9a%84%e5%8a%9f%e8%83%bd%ef%bc%88%e9%99%84%e4%bb%a3%e7%a0%81.html

关于作者: 火云技术网

热门文章

发表评论

您的电子邮箱地址不会被公开。

6条评论

  1. Wow that was unusual. I just wrote an very long comment but after I clicked submit my comment
    didn’t show up. Grrrr… well I’m not writing all that over again. Anyways,
    just wanted to say fantastic blog!

  2. Write more, thats all I have to say. Literally, it seems as though you
    relied on the video to make your point. You obviously know what youre talking about, why
    throw away your intelligence on just posting videos to your weblog when you could be giving us something informative
    to read?

    area 52 delta 8 THC products –

    area 52 delta 8 THC products –

    delta 8 area 52 – delta 8 THC for sale area 52

    buy delta 8 THC area 52 –

    delta 8 carts Area 52 –

  3. I like the valuable information you provide in your articles.
    I’ll bookmark your blog and check again here regularly.
    I’m quite certain I’ll learn a lot of new stuff right here!
    Best of luck for the next!

    Area 52 delta 8 carts –

    Area 52 delta 8 carts –

    Area 52 delta 8 carts – Area 52 delta 8 carts

    delta 8 THC for sale area 52 –

    delta 8 THC for sale area 52 –

  4. Way cool! Some very valid points! I appreciate you penning this post plus the rest of the website is very good.

  5. When I initially commented I clicked the “Notify me when new comments are added” checkbox and now each time a comment is
    added I get four emails with the same comment. Is there any way you can remove
    me from that service? Thanks!

    my site ::

  6. Just desire to say your article is as astonishing.
    The clearness on your post is just excellent and i
    can assume you’re a professional in this subject. Well
    with your permission allow me to take hold of your feed to stay up
    to date with impending post. Thanks one million and please keep up
    the enjoyable work.

网站地图