Replies: 3   Views: 426
Pdf conversion: table cell padding stripped
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by Lochspring  · 15-11-2021 - 13:27

HI.  We're using PHPDocx 10 here for our HTML to DOCX/PDF conversion.  We have managed to get our docx files to generate pretty much the way we want, complete with using WordStyles for the control over the look and feel, by and large.  However, we're running into some problems with table cell padding.  

Attached, please find a link to a  GDrive folder with copies of the documents I reference here.  There, you'll find a copy of the Sample docx Im starting with.  As you can see in the docx, there are .16" paddings inside each cell (applied to whole table via WordStyle). When I run this through libreoffice's converter directly, via the soffice CLI command, I get the document marked as Sample - CLI.pdf, which has my padding correctly applied.  When I run it through Sample_1.php in the transform document examples, I get the document marked Sample - PHP.pdf.  My cell paddings have all been set back to Word Default.

What's happening here?  PHPDocx appears to be ignoring PARTS of the Wordstyle on conversion, while Libreoffice honors them properly. I don't see any differences in the code chain leading from the transformDocuments command to the Libreoffice conversion call that would affect docment structure, and since I'm starting with a prebuilt docx, there should be no generation/alteration required to get through conversion, I should think.  What am I missing?

Posted by admin  · 15-11-2021 - 13:51


The problem is that the attached PDF documents have not been generated with the same version of LibreOffice (you can read this same information with a PDF viewer):

  • Sample - CLI.pdf: generated with LibreOffice 7.1
  • Sample - PHP.pdf: generated with LibreOffice 6.0

LibreOffice 6.0 is a very old version and it's not returning a good conversion. Please use LibreOffice 7 to get a proper conversion. You have not used the same version of LibreOffice: LibreOffice 7.1 in CLI and LibreOffice 6.0 with PHP.

If your server has more than one version of LibreOffice installed, please check you are setting the path in config/phpdocxconfig.ini to the correct version of LibreOffice you want to use. For example, if LibreOffice 7 is installed in /opt/libreoffice7.1:

; libreoffice installation path, absolute path
path = "/opt/libreoffice7.1/program/soffice"


Posted by Lochspring  · 15-11-2021 - 17:29

Fair enough.  The next immediate question, then, is will PHPDOCX 10 encounter any difficulties if I ensure that my environment is running Libreoffice 7?  We're in the process of upgrading to 12, but it's a couple of weeks out to complete testing and squashing bugs, and I'd like to get a fix out for my PDF clients as soon as I can.

Posted by admin  · 15-11-2021 - 17:50


You can use phpdocx 10 with LibreOffice 7, except generating hyperlinks with active links that requires using an existing character style (feature supported since phpdocx 11 in addLink, embedHTML  and replaceVariableByHTML methods). On (Preparing the documents for conversion when using the LibreOffice method section) you can read some recommendations when using the conversion plugin based on LibreOffice.