第一步:yum install openoffice.org-brand openoffice.org-core openoffice.org-java-common xvfb openoffice.org-writer openoffice.org-calc openoffice.org-l10n-zh-cn openoffice.org-l10n-zh-tw python-uno openoffice.org-draw openoffice.org-impress
第二步:启动命令:/usr/lib64/openoffice.org3/program/soffice --accept="socket,host=localhost,port=8100;urp;StarOffice.ServiceManager" --norestore --nofirststartwizard --nologo --headless &
如果启动成功,则服务部署完成;如果启动失败,报如下错误的话,需要进行第三步。
/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)
第三步:在 Centos上作为服务启动
3.1 需要安装Xvfb,是一个虚拟XServer
#yum install Xvfb
#yum install xorg-x11-server-Xvfb.x86_64
3.2 在/etc/init.d/创建服务启动脚本
下面是修改后适合Centos 6.3的 脚本内容
#vi /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/openoffice.org3/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
#chmod +x /etc/init.d/soffice
#chkconfig soffice on
#service soffice start
ps -ef|grep soffice
第四步:测试:
/usr/local/jdk/bin/java -jar jodconverter-2.2.2/lib/jodconverter-cli-2.2.2.jar test.doc 1.pdf
第五步:中文乱码
将simhei.ttf和simsun.ttc拷贝到/usr/share/fonts目录下,然后运行fc-cache命令更新字体缓存。然后重启soffice服务,重新测试