This library has been developed and tested under GNU/Linux (Gentoo Linux) and Windows XP SP1 operating systems on Intel x86 plataform using latest version of both Apache web server and PHP (currently Apache 2.0.52 and PHP 4.3.10). OpenOffice.org application version to test document conversion is actually 1.1.4.
If you test it under another different operating system/plataform, please write me and let me know your experiences.
PHP version 4.3.x with the extensions:
ActiveLink PHP XML 0.3.4 (Class for handling XML trees, distributed under GNU LGPL license)
All versions of PHP DocWriter contain the latest version of this package. You don't need to download it separately.
- OpenOffice.org v1.1 is only needed for automatic document conversion to other formats. To LaTeX and XHTML conversion you need to download and install the export filters from Writer2Latex project.
- Installation of a web server is optional (it can work from a console)
To install this library, just download and unpack the package in a directory you want.
Note for Gentoo Linux users.As an alternative method to install the library, Gentoo Linux users can also download the current ebuild and uncompress it into the <portage's overlay directory>/www-apps directory. Then you only need to type from a console (as root): # emerge phpdocwriter This command will download and install PHP Docwriter at /usr/share/webapps/ and at your default virtual host location (usually /var/www/localhost/htdocs/). After this, you can install the library for any other virtual host if you want by typing: # webapp-config -I -h <host> -d /mywebapp/libs/ phpdocwriter 0.3 For more information see the webapp-config(8) man page.
If you only want to create OpenOffice.org XML documents, you can skip the next section (Document conversion), because there is nothing else to install or configure.
As we explained already, this library can only generate OpenOffice.org XML documents (that is, StarOffice/OpenOffice.org documents). Once the document has been generated, it can communicate with OpenOffice.org application in order to such application do the conversion to another desired format.
This export function uses the Python-UNO bridge included with OpenOffice.org distribution and installed by default from version OpenOffice.org v1.1RC3 though I recommend to install the last one (v1.1.4). You don't need to worry about python installation because OpenOffice.org comes with its own python 2.2.2 runtime.
This method follow the client-server architecture, you need at least one OpenOffice.org installation (working as client and server) or one installation working as client (the machine where PHP DocWriter runs) and other installation working as server (the machine that converts documents).
Note.For this version of classes, client and server needs to be the same machine.
Configuration at the server side
- Close all OpenOffice.org instances (even the quickstarter).
- To make OpenOffice.org listen only for one session execute from shell: # <OfficePath>\soffice "-accept=socket,host=localhost,port=2002;urp;"
- To make OpenOffice.org listen whenever it is started, open the file
in an editor, and look for the element <node oor:name="Office"/>. This element contains
<prop/> elements. Insert the following <prop/> element on the same level as the existing elements:
<prop oor:name="ooSetupConnectionURL" oor:type="xs:string">
This setting configures OpenOffice.org to provide a socket on port 2002, where it will serve connections through the UNO remote protocol (urp).
Note on Linux machines.OpenOffice.org application need a X session to run. If you are a console user, you need to create a new one. To do it, from a console type # nohup /usr/X11R6/bin/Xvfb :25 -screen scrn 800x600x32 & to start a new session.
Don't forget to export DISPLAY variable # DISPLAY=":25" <OfficePath>\soffice "-accept=socket,host=localhost,port=2002;urp;" And use # /usr/bin/killall Xvfb when you want to kill the X session.
Configuration at the client side
At the client side you need to fill in several files with the with appropiate values.
- Edit the file conf/config.php and change the value of the constant pdw_tmpdir (only if necessary). This constant must contain a valid path of a temporary directory where PHP DocWriter could write/read temporary files (this files are created during the process of conversion).
- Edit also the export script file (conf/export.bat for windows, conf/export.sh for linux). You have to fill in two paths, OpenOffice.org pyhton executable path (something like <OfficePath>/program/python.sh) and python script file path (absolute path to export.py file).