在HTML5在线预览PDF格式的代码
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了在HTML5在线预览PDF格式的代码,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1795字,纯文字阅读大概需要3分钟。
内容图文
![在HTML5在线预览PDF格式的代码](/upload/InfoBanner/zyjiaocheng/388/92be9d2207e1460c90bc805a8c3e15a5.jpg)
简介
PDF.js is a Portable Document Format (PDF) viewer that is built with HTML5.
PDF.js is community-driven and supported by Mozilla Labs. Our goal is to create a general-purpose, web standards-based platform for parsing and rendering PDFs.
开源地址:https://github.com/mozilla/pdf.js
下载后不能直接使用,需要重新构建,不熟悉将会非常麻烦
构建好的程序包:build_jb51.rar
示例
引用文件,直接复制下文可以直接使用
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>课程详情</title> <style type="text/css"> </style> <script src="~/Scripts/jquery-1.10.2.min.js"></script> <script src="~/Scripts/plugins/pdfjs/pdf.js"></script> <script src="~/Scripts/plugins/pdfjs/pdf.worker.js"></script> <script type="text/javascript"> var var_filepath = decodeURIComponent("@filepath");//不能跨域 var var_win_height = $(window).height(); $(document).ready(function () { resetPlayerSize(); }); $(window).resize(function () { resetPlayerSize(); }); function resetPlayerSize() { var_win_height = $(window).height(); $(".tmPlayer").css({ "height": var_win_height + "px" }); } </script> </head> <body style="margin: 0;overflow: hidden"> <p id="tmPlayer" class="tmPlayer" style="height: 557px; width: 100%; height: 100%"></p> <script type="text/javascript"> $('.tmPlayer').html('<iframe frameBorder="0" scrolling="no" src="/Scripts/plugins/pdfjs/generic/web/viewer.html?file=' + var_filepath + '" style="width:100%; height:100%;"></iframe>'); </script> </body> </html>
以上就是本文的全部内容,希望对大家的学习有所帮助,更多相关内容请关注PHP中文网!
相关推荐:
HTML5如何实现视频直播功能
HTML5 实现访问本地文件的方法
以上就是在HTML5在线预览PDF格式的代码的详细内容,更多请关注Gxl网其它相关文章!
内容总结
以上是互联网集市为您收集整理的在HTML5在线预览PDF格式的代码全部内容,希望文章能够帮你解决在HTML5在线预览PDF格式的代码所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。