Conversion plugin phpdocx

Preparing the templates for their conversion and exporting the charts

Preparing the templates for conversion

To achieve the highest quality when transforming a document, it is advisable to follow some good practices:

  • Set the sizes of the tables manually when using addTable or embedHTML methods. So, instead of keeping the sizes with automatic values according to the content, indicate specific values for each row, column and cell.
  • Backgrounds will not be printed, so they won't appear in the final PDF.
  • Headers and footers are best transformed if their content is in a table. This allows to place correctly each header and footer element.
  • To hide tables borders, erase them cell by cell. If you generate the DOCX from HTML with the embedHtml method, hide the border in each <td>.
  • Choose font types available in the operating system where the conversion plugin is running. Linux, Windows and macOS allow to add new fonts easily.
  • LibreOffice has some minor differences in default sizes and distances compared with MS Word. It is recommended to check these values; just open the document with LibreOffice to adjust them.
  • In order to achieve a conversion as much close as possible to the original content, you can create the DOCX template with LibreOffice. LibreOffice 4.3 and higher allows to save documents in DOCX format (File > Save as > Microsoft Word 2007-2013 XML (.docx)). These files are fully compatible with MS Word.
  • Avoid to the greatest extent possible using absolute positions and place the contents in the document with elements like tables.
Exporting the charts

Same as with pictures, it is possible to export existing charts in a DOCX document to PDF.

LibreOffice comes with Word graphic charts support. It runs a straight conversion with no extra configurations.

In the case of OpenOffice, it is necessary to install one of the following PHP libraries:

Unzip the chosen library in the lib directory with the name “jpgrah” or “ezcomponents”.

Running with JpGraph, you may encounter this error message:

  • '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.’)',

This is due to an incompatibility with the PHP version.

To fix this, modify the file gd_image.php of JpGraph commenting the line JpGraphError::RaiseL(25128); of the SetAntiAliasing method.

Next - Other conversion methods