• 在线文档预览方案汇总


    http://www.cnblogs.com/yanweidie/p/4516164.html
    http://www.cnblogs.com/yefengmeander/archive/2012/12/05/2887545.html
    http://blog.csdn.net/hezudao25/article/details/13291941



    Word、Excel、PPT、PDF在线预览的实现方法有什么,我暂时知道可以用flash和html实现预览
    最好不要用flash预览,希望能用html5。
    暂时我查到的技术有:
    flash预览有:flexpaper(支持Word、Excel、PPT、PDF播放,但是需要转为swf)
    转换为hmtl的有:OpenOffice + Jodconverter(支持Word、Excel、PPT转为html)
    但是OpenOffice + Jodconverter转Word、Excel、PPT的格式有些问题,请问各位大神有什么其他的方法呢?而且使用OpenOffice时需要启动服务,这点比较坑爹,请问有什么解决方法?


    I found a solution to my issue and after a request, will post it here to help others. Apologies if I missed any details, it's been a while since I worked on this solution.

    The first thing that is required is to install Openoffice.org on the server. I requested my hosting provider to install the open office RPM on my VPS. This can be done through WHM directly.

    Now that the server has the capability to handle MS Office files you are able to convert the files by executing command line instructions via PHP. To handle this, I found PyODConverter: https://github.com/mirkonasato/pyodconverter

    I created a directory on the server and placed the PyODConverter python file within it. I also created a plain text file above the web root (I named it "adocpdf"), with the following command line instructions in it:

    directory=$1
    filename=$2
    extension=$3
    SERVICE='soffice'
    if [ "`ps ax|grep -v grep|grep -c $SERVICE`" -lt 1 ]; then
    unset DISPLAY
    /usr/bin/soffice -headless -accept="socket,host=127.0.0.1,port=8100;urp;" -nofirststartwizard &
    sleep 5s
    fi
    python /home/website/python/DocumentConverter.py /home/website/$directory$filename$extension /home/website/$directory$filename.pdf
    This checks that the openoffice.org libraries are running and then calls the PyODConverter script to process the file and output it as a PDF. The 3 variables on the first three lines are provided when the script is executed from with a PHP file. The delay ("sleep 5s") is used to ensure that openoffice.org has enough to time to initiate if required. I have used this for months now and the 5s gap seems to give enough breathing room.

    The script will create a PDF version of the document in the same directory as the original.

    Finally, initiating the conversion of a Word / Excel file from within PHP (I have it within a function that checks if the file we are dealing with is a word / excel document)...

    //use openoffice.org
    $output = array();
    $return_var = 0;
    exec("/opt/adocpdf {$directory} {$filename} {$extension}", $output, $return_var);
    This PHP function is called once the Word / Excel file has been uploaded to the server. The 3 variables in the exec() call relate directly to the 3 at the start of the plain text script above. Note that the $directory variable requires no leading forward slash if the file for conversion is within the web root.

    OK, that's it! Hopefully this will be useful to someone and save them the difficulties and learning curve I faced.

    文档查看器:http://www.oschina.net/news/35267/jquery-pdf-viewers
    基于html5方案
    http://www.cnblogs.com/studyzy/p/5338398.html
    https://www.oschina.net/question/2361030_248671
    http://blog.csdn.net/czx33859066/article/details/6040836
    http://doc.okbase.net/u010506940/archive/127415.html

  • 相关阅读:
    Mysql子查询、关联查询
    Mysql 注意细节
    IE和FF区别关于css和js
    php 使用curl模拟登录人人(校内)网
    解析php mysql 事务处理回滚操作
    《Linux内核设计的艺术》学习笔记(二)INT 0x13中断
    《Linux内核设计的艺术》学习笔记(一)从开机加电到加载三个汇编源码
    CSS笔记(一)CSS规则
    HTML笔记(七)head相关元素<base> & <meta>
    HTML笔记(六)文档类型
  • 原文地址:https://www.cnblogs.com/fer-team/p/7205815.html
Copyright © 2020-2023  润新知