PHP前端开发

在HTML5在线预览PDF格式的代码

百变鹏仔 2个月前 (10-18) #H5教程
文章标签 在线

本篇文章主要介绍了HTML5在线预览PDF的示例代码,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧

简介

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

示例

引用文件,直接复制下文可以直接使用

nbsp;html&gt;    <meta>    <title>课程详情</title>    <style>    </style>    <script></script>    <script></script>    <script></script>    <script>        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>     <p></p>    <script>        $(&#39;.tmPlayer&#39;).html(&#39;<iframe frameBorder="0" scrolling="no" src="/Scripts/plugins/pdfjs/generic/web/viewer.html?file=&#39; +            var_filepath +            &#39;" style="width:100%; height:100%;">&#39;);    </script>

以上就是本文的全部内容,希望对大家的学习有所帮助,更多相关内容请关注PHP中文网!