Conversion plugin phpdocx

Common problems and possible errors

Common problems and issues
  • altChunk tag: The addExternalFile and replaceVariableByExternalFile methods use the Word altChunk internal tag. This allows to insert external files in a Word document. This tag is MS Word supported only, so it's not compatible with the conversion plugin.
  • Script method: The transformDocument method has two options to transform the documents: direct and script. If the default value doesn't work, try using the script method.
  • macOS and OdfConverter: macOS users must use LibreOffice as the transformation method, as OdfConverter is not available for this OS.
  • TOC generation: Since phpdocx 4.6, the TOC generation and transformation when transforming to PDF is supported. Please check the included documentation in the Advanced and Premium packages to generate the TOC when transforming the documents. Since phpdocx 8.0, the TOC generation is supported for DOCX documents as well.
  • SELinux: 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.
  • Error rename: The rename PHP method may show an error quite similar to rename(tmp/document.pdf,tmp/output.pdf) when you try the conversion and actually get the DOCX you wanted to create. That error is due to the impossibility of converting the document through LibreOffice. See Debugging OpenOffice and Debuggin LibreOffice for more information.
  • Font families: To generate PDFs with the same fonts as the original document you need those fonts installed in your operating systems. All operating systems allow to install them easily. See the Cookbook entry on good practices about fonts for more information.
  • Opened LibreOffice: To work in headless mode and perform all conversions it is mandatory to close LibreOffice. If you have any LibreOffice window open, close all of them before doing the transformations.
LibreOffice Linux common problems and issues
  • CentOS: If you work with CentOS and install the LibreOffice packages from the official repositories, it is mandatory to install the libreoffice-headless package to run the conversion plugin.
  • .config directory: LibreOffice needs permissions to read and write in the .config directory on the PHP HOME. You can obtain it with this line of code:

    If this directory doesn't exist you have to create it with rwx permissions for the LibreOffice or 777 user.

    If you get an empty value as home folder, you can change the PHP configuration to set a custom one, or set a value dynamically using putenv. For example, to set /var/www as HOME folder:

LibreOffice Windows common problems and issues
  • phpdocx set up file: If the path to LibreOffice in the config/phpdocxconfig.ini file contains spaces, you have to wrap it between single quotation marks, e.g.:
  • IIS web server: To convert files properly with this web server you have to grant rw access to the IIS user (IUSR and IIS_IUSRS as default) for the target directory, and then check the following set up PHP line:
OpenOffice Linux common problems and issues
  • temporary directory: If you run OpenOffice along with OdfConverter, it is necessary to create a temporary ODT document.
    To create the ODT it is mandatory to have read and write permissions in a temporary directory. If you can't use the OS temp folder, the transformDocument method allows to set a new one.
  • .wapi directory: For proper functioning with a web server like Apache, you must create a .wapi directory in the root of the web server.
    An example could be /var/www/.wapi, with read and write permissions for the corresponding user.
    The absence and need of this directory, and the path where it has to be located, is generated in the log files of the web server you use.
  • wrong version of libtiff: If the conversion returns an error message related to the version of the libtiff library, you can create a symbolic link to solve it.
    For example, if you have running and you get an error related to, write the following lines:
Next - Debugging LibreOffice