Skip to content
Advertisement

How to Generate PDF file from .docx from linux server?

We use on our production server: Ubuntu 10 server edition. We need to create a document that includes text , images and tables in the content and images in header and footer. Now we use http://phpword.codeplex.com/ to create it and it does a great job generating docx files but we need the pdf version of that file. How can we convert the docx to pdf ? Or any other library to generate pdf files that allows images in header /footer ? Using windows components is not a solution. Using openOffice maybe? can it be used on an ubuntu server edition ? any other convertor for docx to pdf in linux – server environment ?

Advertisement

Answer

If your documents include images using OpenOffice is definitely a good solution. Check out PyODConverter if you want to try this out.

If it’s simple text you might want to consider using a simpler solution like PHPDocx, unoconv, AbiWord or LiveDocx.

I’ve used OOo in the past for this (and still use to convert Odt files to Pdf) and it works great. 🙂 I only got one problem with it, but has already been resolved. You can check that out here: Docx to pdf using openoffice headless way too slow

EDIT:

I’ve created a bash script “/etc/init.d/openoffice” to start openoffice with the correct options. The file contents are the following:

#!/bin/bash
# openoffice.org headless server script
#
# chkconfig: 2345 80 30
# description: headless openoffice server script
# processname: openoffice

OOo_HOME=/usr/lib/openoffice
SOFFICE_PATH=$OOo_HOME/program/soffice

if [ "$1" == "start" ]; then
 echo "Starting OpenOffice headless server"
 $SOFFICE_PATH --headless --accept="pipe,name=beubi_OOffice;urp;StarOffice.ServiceManager" --invisible --norestore --nodefault --nolockcheck --nofirstwizard
 exit
fi

if [ "$1" == "stop" ]; then
 echo "Stopping OpenOffice headless server."
 killall -9 soffice.bin && killall -9 soffice
 exit
fi

echo "Usage: $0 {start|stop}"
exit 1

Then just set execute permission on it and you should be ready to go.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement