Summary

Get the necessary software components

The following components are needed:

Create the offi2pdf user and setting up your environment in Linux

Creating the user

For security reasons, it is highly recommended to run office2pdf under a dedicated user; let's call him offi2pdf (in order to stick with the 8 character limitation of Unix).

To create him, execute the following command:


root:/> useradd -m offi2pdf

Unpacking office2pdf

Unpack the office2pdf package:


office2pdf:~> tar xfzv office2pdf-0.10.6.tar.gz
Also, a number of directories will be needed later in this installation:

office2pdf:~> mkdir -p ~/fonts/afm
office2pdf:~> mkdir -p ~/fonts/ttf
office2pdf:~> mkdir -p ~/wininstall

Installing the printer (if needed)

Make sure that on your box, there is at least one printer defined (details are not important, but a printer must be defined). You can for instance put the following into your /etc/printcap:

office2pdf:
N.B. The presence of the printer "definition" in the /etc/printcap is enough. No need to even install any print queuing system, such as lpd or cups. The printer definition doesn't even need to be complete. Of course, this step can be skipped if there are already printers defined on the system.

Compiling and installing xte


offi2pdf:~> wget http://hoopajoo.net/static/projects/xautomation-0.96.tar.gz
offi2pdf:~> tar xfzv xautomation-0.96.tar.gz
offi2pdf:~> cd xautomation-0.96
offi2pdf:~/xautomation-0.96> ./configure
offi2pdf:~/xautomation-0.96> make
offi2pdf:~/xautomation-0.96> su
root:/home/offi2pdf/xautomation-0.96> make install

Install wine

If not yet done, install a recent version of wine. As root, type:


root:/> rpm -U wine-0.9.21-SuSELinux101.i586.rpm
As offi2pdf, run wine once, so that it creates a default config in his .wine directory:

offi2pdf:~> wine notepad.exe
By doing a File->Print, verify that wine sees your printer defined above. Exit notepad, and edit .wine/config:

Optionnally, Install the wine fonts

Optional installation of fonts is described here. The generated PDF documents look better with the relevant fonts installed, and are also smaller.

If you chose not to install any optional fonts, you may need to fix the path to generic.ppd in the ~/.wine/config:


[ppd]
"generic" = "/usr/share/wine/generic.ppd"
This may depend on wine version. For instance, wine-20040813 on SuSE has the file located on /usr/share/wine/generic.ppd, but the default config file generated by wine points to /usr/lib/wine/generic.ppd. Obviously, if the config file already points to an existing generic.ppd file, no action is necessary.

Install the viewers

Put the viewers (Word viewer, Excel viewer) and Power Point Viewer into the ~/wininstall directory.

Then install them into wine:


offi2pdf:~> cd wininstall
offi2pdf:~/wininstall> wine wd97vwr32.exe
offi2pdf:~/wininstall> wine xlViewer.exe
offi2pdf:~/wininstall> wine PPView97.exe

Testing

Set up the Vnc password


offi2pdf:~> cd office2pdf
offi2pdf:~/office2pdf> vncpasswd .vncpass

Configuration

Office2pdf is configured using the office2pdf.cfg file. The configuration file is extensively commented. Most default settings are ok, and can be safely left unchanged. However, the following settings should be changed:
Name Meaning
$sender Sender address from which replies will be sent.
$defaultSubject Subject to use for reply mail, if user didn't include any
$boilerplate Small introductory text to be included in reply messages.

Start the Office2pdf's worker

In one window, start the worker as follows:

offi2pdf:~> cd office2pdf
offi2pdf:~/office2pdf> bin/worker.pl
Optionally, from another Window, open up a viewonly Vnc session to localhost:99 in order to observe how office2pdf works...:

offi2pdf:~> vncviewer -viewonly :99
The -viewonly option is to avoid accidentally disturbing office2pdf when moving the mouse over the Vnc windows, etc.

Drop a Word or Excel file into the incoming folder. This is best done atomically with a copy followed by a move, rather than directly copying it. A nice example of such a file is the README.DOC included with the word viewer itself.


offi2pdf:~> cp ".wine/fake_windows/Program Files/WordView/README.DOC" .
offi2pdf:~> mv README.DOC office2pdf/flatIn
When it is done (about a minute afterwards), your pdf file should appear in office2pdf/flatOut.

If something doesn't work, check using vncviewer where exactly it is stuck. In case of failure, you can then also launch vncviewer without the -viewonly option, and "help" office2pdf by manually performing the action where it seems stuck (opening the printer dialog, clicking print, etc.). When reporting a bug, include a brief description of where it seems to be stuck, and what happens when you "help" it.

Next, you can test whether it is capable of replying to mails:

A minute or so afterwards you should receive a mail with your PDF attachment.

Permanent installation

Disabling the Wine debugger

If an application (such as the office viewers) crashes, wine starts up a debugger. While this is handy in an interactive environment, it doesn't make sense for an unattended daemon who will stay blocked on the debugger until it hits its timeout.

Thus, in order to give faster responses on failed jobs, apply the nodebug registry tweak:


regedit t:nodebug.reg
(Yes, this does not actually call echo... But hey, it disables the debugger!)

Freezing wine tree

Now that your wine is setup, protect it with chown against any further modifications:


root:/> chown -R root ~offi2pdf/.wine
Should any further intervention be necessary, you can open it up again as follows:

root:/> chown -R root ~offi2pdf/.wine

Installation of init script

This section applies to SuSE distributions. On other distributions (such as RedHat), small adaptations to the startup script and to this procedure may be needed. If needed, edit the settings in bin/office2pdf (OFFICE2PDF_USERNAME and OFFICE2PDF_PATH), and then copy it over to /etc/init.d, and start it:

root:/> cp ~offi2pdf/office2pdf/bin/office2pdf /etc/init.d
root:/> chkconfig --add office2pdf
root:/> /etc/init.d/office2pdf start
The above makes sure that office2pdf is started automatically after each reboot.

Mail setup

Put the following into offi2pdf's .forward file. N.B. The .forward file must belong to offi2pdf and should not be writable by any other user:

"|/home/offi2pdf/office2pdf/bin/unpacker.pl"
Optionally, put an alias into /etc/aliases, and run newaliases:

office2pdf: offi2pdf
In order to avoid authentication warnings in the headers of the mails sent out by office2pdf, you can add the offi2pdf user to /etc/mail/trusted-users and do an /etc/init.d/sendmail reload Your office2pdf is now ready and accepts .doc and .xls mails. Test it out by sending it some Word documents. In case of problems, you can still use vncviewer to check out where it is blocked.

Troubleshooting / Reporting bugs

Valid HTML 4.01!


Last modified: Fri Sep 22 12:01:46 CEST 2006