作用:linux下文檔服務器上傳文檔轉換成pdf文檔,再由swftool工具轉換成swf文件實現在線預覽環境:OS centos6.5 java環境軟件包:Apache_OpenOffice_4.1.3_Linux_x86-64_install-rpm_zh-CN.tar.gz http://sourceforge.net/PRojects/openofficeorg.mirror/files/4.1.3/binaries/zh-CN/Apache_OpenOffice_4.1.3_Linux_x86-64_install-rpm_zh-CN.tar.gz jodconverter-2.2.2.zip swftools-2013-04-09-1007.tar.gz http://www.swftools.org/swftools-2013-04-09-1007.tar.gz一、openoffice的安裝1、下載linux下的安裝包http://www.openoffice.org/ http://sourceforge.net/projects/jodconverter/files/我下載的是最新版本# cd /usr/local/src# wget http://sourceforge.net/projects/openofficeorg.mirror/files/4.1.3/binaries/zh-CN/Apache_OpenOffice_4.1.3_Linux_x86-64_install-rpm_zh-CN.tar.gz2、解壓安裝#tar zxvf Apache_OpenOffice_4.1.3_Linux_x86-64_install-rpm_zh-CN.tar.gz# cd zh-CN/RPMS# rpm -ivh *.rpm #安裝所有rpm包3、進入到desktop-integration目錄,選擇安裝相關的套件,我選擇的是redhat# rpm -ivh openoffice4.1.3-redhat-menus-4.1.3-9783.noarch.rpm4、啟動openoffic服務,安裝在/opt下進入opt下的openofiice4目錄:# cd /opt/openoffice4/program啟動服務# soffice -headless -accept="socket,host=127.0.0.1,port=8100;urp;" -nofirststartwizard & 查看端口已經正常啟動;二、jodconvert的安裝測試下載jodconvert包然后解壓,找到jar包執行路徑/usr/local/jodconverter/lib/jodconverter-cli-2.2.2.jar測試java -jar /usr/local/jodconverter/lib /jodconverter-cli-2.2.2.jar test.doc test.pdf發現生成pdf文件,說明openoffice安裝啟動成功服務加入開機自啟動#vim /etc/rc.local#!/bin/sh## This script will be executed *after* all the other init scripts.# You can put your own initialization stuff in here if you don't# want to do the full Sys V style init stuff.#route add default gw 192.168.50.1soffice -headless -accept="socket,host=127.0.0.1,port=8100;urp;" -nofirststartwizard &touch /var/lock/subsys/local三、swftools安裝 1、下載地址 http://www.swftools.org/download.html# wget http://www.swftools.org/swftools-2013-04-09-1007.tar.gz2、安裝依賴包# yum -y install giflib-devel libjpeg-develfreetype-devel t1lib-devel zlib3、解壓# tar zxvf swftools-2013-04-09-1007.tar.gz# cd swftools-2013-04-09-1007# ./configure5.編譯安裝# make && make install6、查詢安裝成功后的which pdf2swf目錄#which pdf2swf/usr/local/bin/pdf2swfQS:后來發現安裝openoffice轉換效果并不理想,首先是速度較慢,再就是很多舊文檔,文件格式支持性不好,部分文檔不能轉換,于是乎安裝libreoffice步驟與openoffice差不多1、官網打開http://zh-cn.libreoffice.org/download/libreoffice-still/2、下載穩定版本http://zh-cn.libreoffice.org/download/libreoffice-still/?type=rpm-x86_64&version=5.2&lang=zh-CN3、下載# wget http://mirrors.ustc.edu.cn/tdf/libreoffice/stable/5.2.5/rpm/x86_64/LibreOffice_5.2.5_Linux_x86-64_rpm.tar.gz下載中文支持包# wget http://download.documentfoundation.org/libreoffice/stable/5.2.5/rpm/x86_64/LibreOffice_5.2.5_Linux_x86-64_rpm_langpack_zh-CN.tar.gz4、解壓,并且到RPMS下,安裝所有的rpm包# rpm -ivh *.rpm5、開啟服務(與openoffice一致)soffice -headless -accept="socket,host=127.0.0.1,port=8100;urp;" -nofirststartwizard & 四、參考文檔:http://blog.csdn.net/cuker919/article/details/46389449