PDF Conversion Plugin: Installation Guide

    This page offers information based on OpenOffice plugin. For further information visit Conversion Plugin page.

Windows platforms

First download OpenOffice from and install it as any other Windows program.

After OpenOffice is installed, you must start it in headless mode. In order to do this, just open a terminal and execute:

This command sets C:\Apps as OpenOffice's path but if you did a custom installation you'd need to replace it with the correct custom path.

You can now test the installation running the following example (copied from examples/easy/Transform.php):

that creates two documents: a DOCX file and the transformed PDF file.

To optimize the PDF conversion quality we recommend you to use OdfConverter for Windows, included in the phpdocx package. By default OdfConverter is used, but you can disable it if you wish when you invoke the transformDocument method:

OdfConverter for Windows requires .NET Framework 2.0. If it is not installed in your server you may download it from Microsoft website.

The transformDocument method uses by default the passthru PHP command to execute OdfConverter and OpenOffice but you can run it using an external script that avoid common Apache issues related to secure servers and/or incorrect server configurations. To run the external script method you need to slightly modify the previous script by invoking the transformDocument method with the following additional parameters:

Common Windows issues

In Windows platforms phpdocx may have some problems accessing the temp folder. You may use a custom temp folder to save the temporary documents generated by OdfConverter by invoking the transformDocument as follows:

where 'tmp_path' is the path to the custom temporary folder. If not specified, by default, OdfConverter tries to use the OS temp folder.

Linux platforms

phpdocx includes a version of Apache OpenOffice for 32-bit OS, but you may use any version of OpenOffice greater than 3.2. If you prefer to install a custom version of OpenOffice instead of the included one, you can download the packages from your distribution or download it from: OpenOffice.org

The only requirement to run OpenOffice is to have Java installed on your computer. Although you can use OpenJDK, the official version from Sun has greater performance and stability.

After OpenOffice is installed, you must start it in headless mode (this is a special way to run OpenOffice that doesn't a graphic server). For this, just open a terminal and execute

This command sets lib/openoffice/opeoffice.org3 as the path to OpenOffice but if you did a custom installation you'd need to replace it to the correct custom path. For example, if you installed the program in /opt directory, you need to execute:

You can now test the installation running the following example (copied from examples/easy/Transform.php):

that creates two documents: a DOCX file and the transformed PDF file.

To optimize the PDF conversion quality we recommend you to use ODFConverter. phpdocx includes both 32-bit and 64-bit versions of this program. By default OdfConverter is used, but you can disable it if you wish when you invoke the transformDocument method:

The transformDocument method uses by default the passthru PHP command to execute OdfConverter and OpenOffice but you can run it using an external script that avoid common Apache issues related to secure servers and/or incorrect server configurations. To use the external script method you need to slightly modify the previous script by invoking the transformDocument method with the following additional parameters:

Common Linux issues

1. Some old Linux distributions use GLIBC 2.5, a version not compatible with the current version of OpenOffice. You can download the latest versions of OpenOffice compatible with GLIBC 2.5 from: http://people.apache.org/~arielch/packages/r1372282-glibc-2.5/.

2. If you get a missing library error/warning message when you run OdfConverter or OpenOffice you need to install them from the repositories of your LINUX distribution.

3. If you're working with SELinux you need to disable it or put the process type or SELinux into permissive mode by using setenforce or semange commands.

4. In some Linux platforms phpdocx may have some problems accessing the temp folder. You may use a custom temp folder to save the temporary documents generated by OdfConverter by invoking the transformDocument as follows:

where 'tmp_path' is the path to the custom temporary folder. If not specified, by default, OdfConverter tries to use the OS temp folder.

5. For a thorough debugging of any problem when using the conversion plugin we recommend you test both programs with the command line interface:

  • Start OpenOffice in headless mode:
    $ lib/openoffice/openoffice.org3/program/soffice -headless -accept="socket,host=127.0.0.1,port=8100;urp;" -nofirststartwizard
  • Make sure there is no output to the terminal or a Java notice, and that OpenOffice keeps running and waiting for callbacks.
  • Then run OdfConverter 32-bit: $ lib/OdfConverter/32/OdfConverter or the 64-bit version: $ lib/OdfConverter/64/OdfConverter
  • If you get a segmentation fault it may be due to the fact that you are not using the correct 32 or 64 bit version.You may detect your OS architecture just by running this command: $ uname -a

6. If you get a .wapi error message, you need to create a new folder in the root of the web folder called .wapi and set read and write access to the Apache user to this folder.

7. If you get the error JpGraphError::RaiseL(25128);//(‘The function imageantialias() is not available in your PHP installation. Use the GD version that comes with PHP and not the standalone version.’) when transforming DOCX with charts to PDF, edit the jpraph gd_image.inc.php file and comment the line pGraphError::RaiseL(25128); of the SetAntiAliasing method.