Conversion plugin phpdocx

Information

Information

The conversion plugin is one of the most remarkable features of phpdocx.

This plugin is available for the Advanced and Premium licenses. It allows to transform documents while keeping their contents and visual appearance. For example DOCX to PDF, DOCX to HTML, DOC to DOCX, PDF to DOCX, DOCX to PNG...

phpdocx includes four transformation methods to achieve the highest quality and best compatibility available:

  • native: it uses native PHP classes to transform documents.

    HTML to DOCX and DOCX to HTML conversions are done using PHP native classes: HTML to Word and Word to HTML.

  • libreoffice: based on LibreOffice. This is the recommended method to transform DOCX to PDF because of its compatibility (Windows, Linux, macOS), performance, flexibility and number of options, for example, support for the generation of TOC contents or comment export.
  • msword: based on MS Word. Only available for Windows. It uses PHP COM methods and requires a MS Word installation.
  • openoffice: based on OpenOffice. Deprecated. It is advisable to choose one of the previous modes. This one is only compatible with Windows and Linux. It remains for compatibility reasons with old phpdocx versions.
Supported document types

The supported document formats depend on the conversion plugin method chosen for the transformation.

native

Source Output
DOCX PDF HTML
HTML DOCX
PDF PNG

libreoffice

Source Output
DOCX PDF (X)HTML DOC ODT PNG RTF TXT
DOC DOCX PDF (X)HTML ODT PNG RTF TXT
ODT DOCX PDF (X)HTML DOC PNG RTF TXT
PDF DOCX DOC ODT RTF PNG TXT
RTF DOCX PDF (X)HTML DOC ODT PNG TXT

Due to format limitations, the PNG transformation only generates the first page of the document using the conversion plugin based on LibreOffice. To transform all DOCX pages to PNG the best approach is transforming DOCX to PDF using this conversion plugin and then use the native conversion plugin to transform PDF to PNG.

msword

Source Output
DOCX PDF DOC
PDF DOCX DOC
DOC DOCX PDF

openoffice

Source Output
DOCX PDF (X)HTML DOC ODT RTF TXT
DOC DOCX PDF (X)HTML ODT RTF TXT
ODT DOCX PDF (X)HTML DOC RTF TXT
RTF DOCX PDF (X)HTML DOC ODT TXT
Which method to use for the conversion?

HTML to DOCX and DOCX to HTML conversions are done using PHP native classes: HTML to Word and Word to HTML.

To transform DOCX to PDF, for the vast majority of projects it is advisable to run the method based on Libreoffice, as it is compatible with Linux, Windows and macOS, converts perfectly a great amount of documents and includes options like comment and form fields export, automatic generation of the TOC content or creation of PDF/A-1 documents, among other features.

If you can only run PHP in the server, the native method is an excellent choice, provided that the documents use the supported contents and styles.

In the event of a compatibility issue with the requisites of the contents of the previous conversion modes or in case of a need of converting PDF documents to DOCX, the preferred method is the one based on MS Word. This method demands a Windows server, PHP COM and MS Word and allows to obtain documents absolutely identical to the original one.

Next - Installation and set up