zoukankan      html  css  js  c++  java
  • web中浏览PDF文件

     1.在web中浏览pdf文件。

     2.支持大多数主流浏览器,包括IE8

     3.参考网址:

    https://pdfobject.com/

    http://mozilla.github.io/pdf.js/

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="viewfile.aspx.cs" Inherits="Web.Student.viewfile" %>
    
    <!DOCTYPE html>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <script src="../Script/jquery-1.7.2.min.js"></script>
        <link rel="resource" type="application/l10n" href="../Plugin/pdfjs/web/locale/locale.properties" />
        <script type="text/javascript" src="../Plugin/pdfobject/pdfobject.js"></script>
        <title>文档预览</title>
    
        <script type="text/javascript">
            $(function () {
                $("#file-container").height($(window).height() - 20);
                $(window).resize(function () {
                    $("#file-container").height($(window).height() - 20);
                });
    
                viewpdf();
    
            });
    
            var viewpdf = function () {var options = {};
                if (PDFObject.supportsPDFs) {
                    //表示浏览器支持内联PDF
                    console.log("Yay, this browser supports inline PDFs.");
                    options = {
                        page: 1,//默认显示第几页
                        fallbackLink: "<p>This is a <a href='<%=FPath %>'>fallback link</a></p>"
                    };
                } else {
                    //表示浏览器不支持内联PDF
                    console.log("Boo, inline PDFs are not supported by this browser");
                    options = {
                        pdfOpenParams: {
                            navpanes: 0,
                            toolbar: 0,
                            statusbar: 0,
                            view: "FitV",
                            pagemode: "none",//thumbs=显示缩略图;none=不显示缩略图。
                            locale: "zh-CN",
                            page: 1//默认显示第几页
                        },
                        forcePDFJS: true,
                        PDFJS_URL: "../Plugin/pdfjs/web/viewer.html"
                    };
                }
                var mypdf = PDFObject.embed("<%=FPath %>", "#file-container", options);
            };
    
        </script>
    </head>
    <body style="margin:0;padding:0;">
        <div id="file-container" style=" 100%; height: 500px;">
        </div>
    </body>
    </html>

     引用的js文件下载地址:http://download.csdn.net/detail/wz122889488/9850544

  • 相关阅读:
    linux 运维
    mariadb replication
    phpmyadmin
    Objective-C设计模式——单例Singleton(对象创建)
    收藏iOS学习资料
    axios拦截器
    vue单页面优化
    html设置http缓存代码
    js数组去重,排序的几种方法
    前端移动端问题
  • 原文地址:https://www.cnblogs.com/wz122889488/p/6897418.html
Copyright © 2011-2022 走看看