How to set up OpenOffice to run in headless mode on Fedora 9
What we wanted was a system set up to convert any OpenOffice document to PDF. Most importantly, we needed to convert Word .doc files to .pdf, but in fact, any OpenOffice file types (.xls, .odt, .txt, .rtf, etc) will work, as long as you install the proper packages / dependencies!
We will be starting OpenOffice in headless mode, which means no GUI. This should be started on boot up, and should just run in the background.
You don’t need to install all the OpenOffice packages if you don’t need them. We are mainly concerned with Word docs, so OoWriter is a must. We are running in headless mode, which means we don’t have a GUI to openoffice. So we can leave out a bunch of unnecessary packages.
- Here’s what we have installed:
openoffice.org-core.x86_64 1:2.4.2-18.3.fc9 installed openoffice.org-headless.x86_64 1:2.4.2-18.3.fc9 installed openoffice.org-pyuno.x86_64 1:2.4.2-18.3.fc9 installed openoffice.org-sdk.x86_64 1:2.4.2-18.3.fc9 installed openoffice.org-writer.x86_64 1:2.4.2-18.3.fc9 installed openoffice.org-writer2latex.x86_64 0.5-2.fc9 installed
If you need to convert Excel spreadsheets, ppt Powerpoint presentations to pdf, you will need to install the corresponding package (ie. openoffice.org-calc, openoffice.org-draw, etc.)
After you have these packages installed, be sure you have the soffice command. By default it is here:
Next, try to start up the service with this command:
$ /usr/lib64/openoffice.org/program/soffice.bin -headless accept="socket,host=localhost,port=8100;urp;" -nofirststartwizard &
#Note: the ampersand (&) allows the command to run in background so you get your shell back.
You can specify whichever port you would like. The -nofirststartwizard flag does exactly that.
Next step is to find a script (client) that can interact with this OpenOffice service.
A few options are:
1. dag’s unoconv (Available from yum)
2. PyODConverter – a cool Python script to do conversions
3. Write your own!
We chose to use PyODConverter. It’s simple to use:
$ PyODConverter.py example.doc example.pdf
Lastly, I mentioned that we want this soffice to start up everytime we reboot.
Simply add the line to your /etc/rc.d/rc.local
# Start up openoffice for fax conversion $ /usr/lib64/openoffice.org/program/soffice.bin -headless accept="socket,host=localhost,port=8100;urp;" -nofirststartwizard
And there you have it. Hope that helps somebody. Happy Conversions!
Hint: If you are getting strange unintelligible errors about “URL seems to be an unsupported one”, it may be that you have not installed a necessary openoffice package. That’s how I discovered I needed OoWriter …