Automatic .sxw/.doc to PDF conversion on Debian
Author: Ward Vandewege. Last update: 2005-10-20

This document describes how OpenOffice can be used on a headless Debian server (Woody/Sarge) to provide automatic conversion of .sxw/.doc documents to PDF.

It's not a very elegant solution, but it works very reliably once installed.

Table of contents

Installing OpenOffice headless

First download the OO 1.1.5 binary. A .torrent can be found here.
Now log in as the user your webserver runs as (this is important!). In Debian, this would be www-data. Then install OO as follows:
$ cd
$ cd OOo_1.1.5_LinuxIntel_install
$ ./install --single
$ cd ..

Disable registration

We need to disable the 'registration' prompt that a freshly installed OO would come up with, the first time it is run. You need to edit the file "~/OpenOffice.org1.1.5/share/registry/data/org/openoffice/Office/Common.xcu". The context diff is:
--- Common.xcu-orig  2005-10-20 16:02:05.000000000 -0400
+++ Common.xcu  2005-10-20 16:02:49.000000000 -0400
@@ -356,6 +356,12 @@
    <prop oor:name="URL" oor:type="xs:string">
     <value>http://www.openoffice.org/welcome/registration.html</value>
    </prop>
+   <prop oor:name="ReminderDate" oor:type="xs:string">
+     <value xsi:nil="true"/>
+   </prop>
+   <prop oor:name="RequestDialog" oor:type="xs:int">
+     <value>0</value>
+   </prop>
   </node>
  </node>
  <node oor:name="I18N">
(See also this thread)

Add a PDF printer

We need to add a 'PDF printer'. This is normally done with the 'spadmin' command, but we're on a headless box, so we can't do that. Just put this pdf-psprint.conf file where the standard psprint.conf file is:
$ cd ~/OpenOffice.org1.1.5/share/psprint
$ mv psprint.conf psprint.conf.old
$ cp ~/pdf-psprint.conf psprint.conf

Install some additional required software

We need to install Xvfb, the Virtual X framebuffer, and its dependencies as follows. Because we are going to use openoffice to print to, we also need some Cupsys support. The gs-gpl package is used for the conversion to PDF.
  Woody:
	 $ su
   #  apt-get install gs-gpl xvfb libdps1 libxaw7 xbase-clients xfonts-base xutils
   #  apt-get install cupsys-bsd cupsys-client libcupsys2 libtiff3g

  Sarge:
	 $ su
   #  apt-get install gs-gpl xvfb libdps1 libxaw7 xbase-clients xfonts-base xutils
   #  apt-get install cupsys-bsd cupsys-client libcupsys2 libtiff4

Configure XVFB, the virtual framebuffer

To start XVFB as a service, and keep it running across reboots, install this startup script into /etc/init.d:
$ Xvfb /etc/init.d/
(downloaded from this forum post) Now make sure that XVFB will be started automatically after a reboot, and start it:
$ update-rc.d Xvfb defaults
$ /etc/init.d/Xvfb start

Conclusion

Finally, test the conversion with this shell script:
$ pdfconversion-xvfb test.doc
The converted document will be put in the home directory of the user running the script (the HOME environment variable is defined in the pdfconversion-xvfb script, and you can change it there). Make sure that the user running the script has write access to that directory!



Ward Vandewege
First version: 2005-10-20
Last update: 2005-10-20

Creative Commons License
This work is licensed under a Creative Commons License.


All trademarks are the property of their respective owners.