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: "

This is a fallback link

" }; } 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="width: 100%; height: 500px;"> div> body> html>

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