Centos上的安裝openoffice+unoconv+swftools (轉)


##############################
#    swftools的安裝     #
##############################
1.安裝所需的庫和組件
yum install gcc* automake zlib-devel libjpeg-devel giflib-devel freetype-devel

2.下載並編譯安裝SWFTOOLS  
cd /usr/local/src
wget http://www.swftools.org/swftools-0.9.1.tar.gz
tar vxzf swftools-0.9.1.tar.gz
cd swftools-0.9.1
./configure --prefix=/usr/swftools
make
make install

============================================

編譯錯誤:

安裝過程中,出現如下錯誤及解決辦法:

錯誤1:

***************************************************

* The following headers/libraries are missing:  ungif gif_lib.h

* Disabling gif2swf tool…

***************************************************

解決辦法:

yum install giflib-devel



錯誤2:

***************************************************

* The following headers/libraries are missing: jpeglib t1lib ungif jpeglib.h freetype t1lib.h gif_lib.h

* Disabling pdf2swf tool…

* Disabling jpeg2swf tool…

* Disabling gif2swf tool…

***************************************************

解決辦法:

yum install giflib-devel libjpeg-devel freetype-devel t1lib-devel



==========================================


3、設置swftools環境變量,使pdf2swf成為一個可執行命令

vi /etc/profile
export PATH=$PATH:/usr/local/swftools/bin/

執行下source /etc/profile 使環境變量生效。

4.安裝xpdf語言包,下載xpdf-chinese-simplified.tar.gz文件,解壓到/usr/local下,編輯add-to-xpdfrc文件,如下:
– 注:需要百度搜索下載xpdf-chinese-simplified.tar.gz 官方的下載太慢了。另外要將windows 字體庫中的常用字體復制一份到/usr/share/fonts/win
vi /usr/local/xpdf-chinese-simplified/add-to-xpdfrc
fontDir /usr/share/fonts/win
displayCIDFontTT Adobe-GB1 /usr/share/fonts/win/simhei.ttf

swftools 對中文亂碼問題

直接將windows系統的相關字體復制到linux字體目錄下windows字體目錄 c:\windows\fontslinux字體目錄 /usr/share/fonts目前我只復制了以下字體

simfang.ttf 仿宋體

simhei.ttf 黑體

simkai.ttf 楷體

simsun.ttf 宋體和新宋體,原文件名simsun.ttc

tahoma.ttf tahoma字體

tahomabd.ttf tahoma字體的粗體形式

verdana.ttf verdana字體

verdanab.ttf verdana字體的粗體形式

verdanai.ttf verdana字體的斜體形式

verdanaz.ttf verdana字體的粗體+斜體形式 在CentOS目錄里新建一個win文件夾

# mkdir /usr/share/fonts/win

# chmod 644 /usr/share/fonts/win/*將以上字體文件復制到/usr/share/fonts/win目錄下執行

# mkfontscale

# mkfontdir # mkfont命令是生成win目錄下所包含的字體的索引信息

# fc-cache # fc-cache命令更新字體緩存

# fc-cache -f –v



5、最后使用如下轉換命令測試:
– 注:1.pdf是要存在的文件
//轉化為swf
pdf2swf -s languagedir=/usr/local/xpdf-chinese-simplified -T 9 -s poly2bitmap -s zoom=150 -s flashversion=9 “/usr/local/src/1.pdf” -o “/usr/local/src/1.swf”

//轉化為txt純文本
pdftotext -q “/usr/local/src/1.pdf” “/usr/local/src/1.txt”

=================================================

##############################
#    openoffice的安裝     #
##############################
1.安裝OpenOffice
yum install openoffice.org-writer   
yum install openoffice.org-calc   
yum install openoffice.org-draw openoffice.org-impress

–注:文件安裝在 /usr/lib/libreoffice/program 下面
啟動openoffice服務

/usr/lib64/libreoffice/program/soffice.bin “–accept=socket,host=localhost,port=8100;urp;StarOffice.ServiceManager” –norestore –nofirststartwizard –nologo –headless &

如果報錯,則虛擬一個x桌面
Xvfb :2 -screen 0 800x600x24 2> /dev/null &

上面命令可能不執行,需要安裝一個server
yum install xorg-x11-server-Xvfb

導入環境變量

export DISPLAY=localhost:0.0

2.安裝OpenOffice SDK3.3
– wget http://ftp.nluug.nl/office/openoffice/stable/3.3.0/OOo-SDK_3.3.0_Linux_x86-64_install-rpm_en-US.tar.gz
tar -zxvf OOo-SDK_3.3.0_Linux_x86-64_install-rpm_en-US.tar.gz
cd OOO330_m20_native_packed-1_en-US.9567/RPMS/
rpm -ivh *.rpm –nodeps

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

用到ms office轉換程序,需要啟動一個服務監聽程序,監聽8100端口。可以通過設置讓系統自動啟動該服務。

1、創建一個執行腳本runoffice,內容如下
#vi /usr/sbin/runoffice
/usr/bin/nohup /usr/lib64/libreoffice/program/soffice.bin “–accept=socket,host=localhost,port=8100;urp;StarOffice.ServiceManager” –norestore –nofirststartwizard –nologo –headless &
#chmod 775 /usr/sbin/runoffice
2、創建啟動腳本
#cat  /etc/rc.d/rc.local

$ cat /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.
xhost +
export     DISPLAY=:0.0
/usr/sbin/runoffice >/var/log/rc.local.log

touch /var/lock/subsys/local

上述腳本會在所有服務啟動完之后執行。

注意

xhost +
export     DISPLAY=:0.0





要不然是不會啟動成功的,會顯示如下錯誤信息
/program/soffice.bin X11 error: Can’t open display:
  Set DISPLAY environment variable, use -display option
  or check permissions of your X-Server
  (See “man X” resp. “man xhost” for details)
加上那兩行就會順利啟動了。

3、在 Centos上作為服務啟動
經過一段時間的試用,發現2中的啟動腳本有時能夠成功,有時不能成功。
經過google搜索,有個服務啟動腳本,經過修改以后,可以適用。

3.1 需要安裝Xvfb,是一個虛擬XServer
In the X Window System, Xvfb or X virtual framebuffer is an X11 server that performs all graphical operations in memory, not showing any screen output. From the point of view of the client, it acts exactly like any other server, serving requests and sending events and errors as appropriate. However, no output is shown. This virtual server does not require the computer it is running on to even have a screen or any input device. Only a network layer is necessary.

它的圖形只存在內存中,而不顯示。

#yum seach Xvfb

#yum xorg-x11-server-Xvfb.x86_64

3.2 在/etc/init.d/創建服務啟動腳本

下面是修改后適合Centos 6.3的 腳本內容

#cat /etc/init.d/soffice





#!/bin/bash

# Boot open office so that Alfresco can do transforms.
# chkconfig: 2345 55 25
# description: OpenOffice Headless
#
# processname: soffice

# source function library
. /etc/rc.d/init.d/functions

RETVAL=0

VDISPLAY=’99′
SOFFICE_PATH=’/usr/lib64/libreoffice/program/’
SOFFICE_ARGS1=”-nofirststartwizard -nologo -headless -display :$VDISPLAY ”
SOFFICE_ARGS2=’-accept=socket,host=localhost,port=8100;urp;StarOffice.ServiceManager’
SOFFICE_PIDFILE=/var/run/soffice.bin.pid

XVFB=/usr/bin/Xvfb
XVFB_ARGS=”:$VDISPLAY -screen 0 800x600x8 -fbdir /var/run”
XVFB_PIDFILE=/var/run/xvfb.pid
start_soffice() {
echo -n $”Starting OpenOffice”
$SOFFICE_PATH/soffice.bin $SOFFICE_ARGS1 $SOFFICE_ARGS2 >/dev/null 2>&1 &
[ $? -eq 0 ] && echo_success || echo_failure
pidof soffice.bin > $SOFFICE_PIDFILE
echo
}
start_xvfb() {
echo -n $”Starting Xvfb”
$XVFB $XVFB_ARGS >/dev/null 2>&1 &
[ $? -eq 0 ] && success || failure
pidofproc Xvfb > $XVFB_PIDFILE
echo
}
start() {
start_xvfb
sleep 3
start_soffice
}
stop() {
echo -n $”Stopping OpenOffice”
killproc soffice.bin
echo
echo -n $”Stopping Xvfb”
killproc Xvfb
echo
}
case “$1″ in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo $”Usage: $0 {start|stop|restart}”
esac





#chkconfig soffice on

/etc/init.d/soffice start

##################################################

3.1 安裝unoconv
wget http://pkgs.repoforge.org/unoconv/unoconv-0.5-1.el6.rf.noarch.rpm
rpm -ivh unoconv-0.5-1.el6.rf.noarch.rpm  –nodeps –force
或直接 yum install unoconv

查看之前安裝的unoconv rpm 命令rpm -qa |grep -i unoconv 刪除它用rpm -e unoconv-0.5-1.el6.rf.noarch
測試:
unoconv -help –nogpgcheck
//!!! 將某個txt轉化為pdf !!!
unoconv -f pdf test.txt

 
hylafax會用到ms office轉換程序,需要啟動一個服務監聽程序,監聽8100端口。可以通過設置讓系統自動啟動該服務。

1、創建一個執行腳本runoffice,內容如下
#vi /usr/sbin/runoffice
/usr/bin/nohup /usr/lib64/libreoffice/program/soffice.bin "--accept=socket,host=localhost,port=8100;urp;StarOffice.ServiceManager" --norestore --nofirststartwizard --nologo --headless &
#chmod 775 /usr/sbin/runoffice
2、創建啟動腳本
#cat  /etc/rc.d/rc.local

$ cat /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.
xhost +
export     DISPLAY=:0.0
/usr/sbin/runoffice >/var/log/rc.local.log

touch /var/lock/subsys/local

上述腳本會在所有服務啟動完之后執行。

注意

xhost +
export     DISPLAY=:0.0

要不然是不會啟動成功的,會顯示如下錯誤信息
/program/soffice.bin X11 error: Can't open display:
  Set DISPLAY environment variable, use -display option
  or check permissions of your X-Server
  (See "man X" resp. "man xhost" for details)
加上那兩行就會順利啟動了。

3、在 Centos上作為服務啟動
經過一段時間的試用,發現2中的啟動腳本有時能夠成功,有時不能成功。
經過google搜索,有個服務啟動腳本,經過修改以后,可以適用。

3.1 需要安裝Xvfb,是一個虛擬XServer

In the X Window System, Xvfb or X virtual framebuffer is an X11 server that performs all graphical operations in memory, not showing any screen output. From the point of view of the client, it acts exactly like any other server, serving requests and sending events and errors as appropriate. However, no output is shown. This virtual server does not require the computer it is running on to even have a screen or any input device. Only a network layer is necessary.

它的圖形只存在內存中,而不顯示。

#yum seach Xvfb

#yum xorg-x11-server-Xvfb.x86_64

3.2 在/etc/init.d/創建服務啟動腳本

下面是修改后適合Centos 6.3的 腳本內容

#cat /etc/init.d/soffice

#!/bin/bash

# Boot open office so that Alfresco can do transforms.
# chkconfig: 2345 55 25
# description: OpenOffice Headless
#
# processname: soffice

# source function library
. /etc/rc.d/init.d/functions

RETVAL=0

VDISPLAY='99'
SOFFICE_PATH='/usr/lib64/libreoffice/program/'
SOFFICE_ARGS1="-nofirststartwizard -nologo -headless -display :$VDISPLAY "
SOFFICE_ARGS2='-accept=socket,host=localhost,port=8100;urp;StarOffice.ServiceManager'
SOFFICE_PIDFILE=/var/run/soffice.bin.pid

XVFB=/usr/bin/Xvfb
XVFB_ARGS=":$VDISPLAY -screen 0 800x600x8 -fbdir /var/run"
XVFB_PIDFILE=/var/run/xvfb.pid
start_soffice() {
echo -n $"Starting OpenOffice"
$SOFFICE_PATH/soffice.bin $SOFFICE_ARGS1 $SOFFICE_ARGS2 >/dev/null 2>&1 &
[ $? -eq 0 ] && echo_success || echo_failure
pidof soffice.bin > $SOFFICE_PIDFILE
echo
}
start_xvfb() {
echo -n $"Starting Xvfb"
$XVFB $XVFB_ARGS >/dev/null 2>&1 &
[ $? -eq 0 ] && success || failure
pidofproc Xvfb > $XVFB_PIDFILE
echo
}
start() {
start_xvfb
sleep 3
start_soffice
}
stop() {
echo -n $"Stopping OpenOffice"
killproc soffice.bin
echo
echo -n $"Stopping Xvfb"
killproc Xvfb
echo
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo $"Usage: $0 {start|stop|restart}"
esac

#chkconfig soffice on


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM