February 2010
« Jan   Mar »

How to convert word document/powerpoint file to pdf or jpg on LINUX

Here are the quick work around to convert.odc/.ppt to image or pdf file.

We need the following packages installed on the server,
a. openoffice
b. imagemagick
c. Java

Installing openoffice

#yum install*
#yum install ImageMagick*

How to verify imagemagick is installed and working

[root@rc-170 ~]# convert logo: logo.gif
[root@rc-170 ~]# convert –version
Version: ImageMagick 6.2.8 04/17/08 Q16 file:/usr/share/ImageMagick-6.2.8/doc/index.html
Copyright: Copyright (C) 1999-2006 ImageMagick Studio LLC

Downloading jodconverter from sourceforge

#mv jodconverter-2.2.2 /usr/local/jodconverter/ ( optional)

Verify the java installed
[root@rc-170 ~]# java -version
java version "1.6.0_14"
Java(TM) SE Runtime Environment (build 1.6.0_14-b08)
Java HotSpot(TM) Server VM (build 14.0-b16, mixed mode)

Now we need to run openoffice as a service. So we can create a init script for this. A sample scripts can be download from here
#vi /etc/init.d/openofficed


case “$1″ in
if [ -f $PIDFILE ]; then
echo “OpenOffice headless server has already started.”
echo “Starting OpenOffice headless server”
$SOFFICE_PATH -headless -accept=”socket,host=,port=8100;urp;” -nofirststartwizard & > /dev/null 2>&1
touch $PIDFILE
if [ -f $PIDFILE ]; then
echo “Stopping OpenOffice headless server.”
killall -9 soffice && killall -9 soffice.bin
rm -f $PIDFILE
echo “Openoffice headless server is not running, foo.”
echo “Usage: $0 {start|stop}”
exit 1
exit 0

In this script I found the open office installation for was different according to the OS architecture. Since my OS is 64 bit it will be “/usr/lib64/” else it is “/usr/lib/” on Linux box.

[root@s15351481 ~]# vi /etc/rc.local then add the line “/etc/init.d/opeofficd start”

# java -jar /usr/local/jodconverter/lib/jodconverter-cli-2.2.2.jar document.ppt mam.pdf
You may use to call it from php using the “exec” funcation.
exec(‘java -jar /usr/local/jodconverter/lib/jodconverter-cli-2.2.2.jar/lib/jodconverter-cli-2.2.2.jar document.doc mam.pdf’);

This program will support for the following conversions,
1. DOC —> PDF
2. DOC —> ODT
3. DOC —> RTF
4. XLS —> PDF
5. XLS –> ODS
6. XLS –> CSV
7. PPT –> PDF
8. PPT —> ODP
9. PPT —> SWF
10. ODT –> PDF
11. ODT —> DOC
12. ODT —> RTF
13. ODS —> PDF
14. ODS —> XLS
15. ODS —> CSV
16.ODP —> PDF
17. ODP —> PPT
18. ODP —> SWF

How do I solve this error ?

[root@rc-040 installation]# /usr/lib/ “-accept=socket,host=localhost,port=8100;urp;StarOffice.ServiceManager” -nologo -headless -nofirststartwizard
/usr/lib/ 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)
[root@rc-040 installation]#

Yoy may need Xserver started on the server. I started the vnc server and execute the service script. Only this method will work.
/etc/init.d/openofficed start

How to check openoffice service is running,

We can test it either by telnet to the listening port or grep it from the process list.

[root@rc-040 ~]# telnet localhost 8100
Connected to localhost.localdomain (
Escape character is '^]'.
[root@rc-040 ~]# netstat -nlp| grep ":8100"
tcp 0 0* LISTEN 21278/soffice.bin
[root@rc-040 ~]#

3 comments to How to convert word document/powerpoint file to pdf or jpg on LINUX

  • Thanks for this article!

    I noticed your article title says convert to .JPG or .PDF, but in the content of your article, “.JPG” is never mentioned, and none of the conversions listed are to .JPG ( i.e. “This program will support for the following conversions…”)

    How could we get these files to be .JPG?

  • Fabar

    Your title says “convert to JPEG” but it seems that the openoffice server cannot convert to image files, just to PDF and some others… Am I missing something? Thank you

Leave a Reply




You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>