好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

HTML5在线预览PDF的示例代码

简介

P DF .js is a Portable Document Format (PDF) viewer t hat is built w IT h HT ML 5.

PDF.js is comm Unity -driven and supported by Mozilla Labs. Our goal is to create a general-purpose, web standa rds -based platform for parsing and rendering PDFs.

开 源 地址: https://github.com/mozilla/pdf.js

下载后不能直接使用,需要重新构建,不熟悉将会非常麻烦

构建好的程序包: build_jb51.rar

示例

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

<!DOCTY PE  html>
<html>
<head>
    < ;m eta http-equiv="Content -t ype" content="text/html; charset=utf-8">
    <title>课程详情</title>
    <style type="text/css">
    </style>
    <script src="~/Scripts/ jq uery-1.10.2.min.js"></script>
    <script src="~/Scripts/plu gin s/pdfjs/pdf.js"></script>
    <script src="~/Scripts/plugins/pdfjs/pdf.worker.js"></script>
    <script type="text/javascript">
         VAR  var_filepath = decodeURI component ("@filepath");//不能跨域
        var var_win_h ei ght = $(window).height();

        $(document).ready(function () {
            reset player Size(); 
        });

        $(window).resize(function () {
            reset play erSize();
        });

        function resetPlayerSize() {
            var_win_height = $(window).height();
            $(". tmp layer").css({ "height": var_win_height + "px" });
        } 
    </script>
</head>

<body style="m arg in: 0;overflow: hidden"> 
    <div id="tmPlayer" class="tmPlayer" style="height: 557px; width: 100%; height: 100%"></div>

    <script type="text/javascript">
        $('.tmPlayer').html('<ifr am e frameBorder="0" scrolling="no" src="/Scripts/plugins/pdfjs/generic/web/viewer.html?file=' +
            var_filepath +
            '" style="width:100%; height:100%;"></iframe>');
    </script>

</body>
</html>

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。

总结

以上是 为你收集整理的 HTML5在线预览PDF的示例代码 全部内容,希望文章能够帮你解决 HTML5在线预览PDF的示例代码 所遇到的问题。

如果觉得 网站内容还不错, 推荐好友。

查看更多关于HTML5在线预览PDF的示例代码的详细内容...

  阅读:18次