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 ?
-
Instead of going from `docx -> pdf` why not directly generate PDF with [`TCPDF`](http://www.tcpdf.org/) ? – ismail Jan 15 '11 at 22:42
-
I will try the TCPDF library. Its a good solution if it support all our requirments – Revelation Jan 16 '11 at 09:58
2 Answers
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.
-
The problem is that we use ubuntu SERVER edition ( no GUI, just console), Can OpenOffice run just in console ? – Revelation Nov 06 '11 at 18:52
-
1Sure. But it needs to run in headless mode and with some other options like "-nofirststartwizard". I've a little script to start/stop it as a service. I'll edit my previous answer and post it there since in this comment I don't have enough space. – Restless Nov 17 '11 at 14:02
You could try docx4j (Java). It can generate pdfs, and images in headers shouldn't be a problem.
Update May 2016
For the last year or so, we've been offering a high quality commercial docx to PDF converter which runs on Linux (and Solaris for that matter); try it at http://converter-eval.plutext.com/ where you can also download an installer.

- 15,352
- 4
- 44
- 84
-
-
1
-
@Mark report any docx4j failure at http://www.docx4java.org/forums/data-binding-java-f16/ – JasonPlutext Mar 28 '12 at 22:41
-
You can use [Carbone](https://carbone.io) to create pdf for docx easily – Guillaume P May 24 '23 at 14:18