Blogger Information
Blog 19
fans 0
comment 1
visits 17970
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
PDF在线阅读
王石磊的博客
Original
920 people have browsed it


PHP实现

<?php

if(!function_exists('read_pdf')) {

   function read_pdf($file) {

       if(strtolower(substr(strrchr($file,'.'),1)) != 'pdf') {

           echo '文件格式不对.';

           return;

        }

    if(!file_exists($file)) {

       echo '文件不存在';

       return;

      }

      header('Content-type: application/pdf');

      header('filename='.$file);

      readfile($file);

 }

}

read_pdf('Python_study.pdf');


为了更好地用户体验,建议你前端采用 FlexPaper在线显示文档组件来显示你的文档,先用PDF2SWF工具将你的pdf转成flash文件,然后用 FlexPaper来显示转换后的swf文件,这样用户浏览速度会很快,就像百度文库那样!但是此方式不支持火狐、IE浏览器(亲测)。

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>

<head>

    <title></title>

    <script type="text/javascript" src="pdfobject.js"></script>

    <script type="text/javascript" src="jquery-1.8.0.min.js"></script>

    <script type="text/javascript">

    $(document).ready(function(){

 

    //第一种方式

    // var myPDF = new PDFObject({ url: "1.pdf" }).embed();

 

    //第二种方式

    var variablename = new PDFObject({ url: "1.pdf" }).embed("pdfobj");

 

    //第三种方式

    // var myembedparams = {

    // url: "1.pdf"

    // };

    // var myPDF = new PDFObject(myembedparams).embed();

});

</script>

</head>

<body>asdfadsfasdf

<div id="pdfobj"></div>

</body>

</html>

  

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!