Conversion plugin

Conversion plugin

Information

The Advanced and Premium licences of phpdocx include the conversion plugin. Its purpose is to convert document formats while keeping their content and visual style at the same time.

The main goal of the conversion plugin is to transform DOCX documents to PDF and HTML. However, it is also compatible with many other formats. This way you can work with the following document formats: DOCX, PDF, (X)HTML, DOC, ODT, PNG, RTF and TXT.

The conversion plugin offers four different execution modes:

  • native: based on native PHP classes.
  • libreoffice: based on LibreOffice.
  • msword: based on MS Word.
  • openoffice: based on OpenOffice.

All execution modes are compatible with Linux, Windows and macOS but the one based on MS Word, which requires a Windows server.

Possible conversions

Thanks to the conversion plugin it is possible to perform the following conversions:

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 PNG RTF
RTF DOCX PDF (X)HTML DOC ODT PNG TXT

You can combine the conversion plugin with the embedHTML method to transform HTML to DOCX, and with TXT2DOCX to convert text files to DOCX.

This way, the phpdocx functionalities allow you to achieve almost any type of conversion.

How to use it

All the conversion plugin execution modes can be run by calling the transformDocument method, available in the CreateDocx class:

or in an independent way by directly instantiating its classes:

Common use cases

These are the most usual test cases when working with the phpdocx conversion plugin:

  • Generate DOCX files from scratch or from templates and convert them to PDF.
  • Create a WYSIWYG HTML editor with CKEditor (or any other editor), convert the resulting HTML to DOCX and finally transform it to PDF, DOC and so on.
  • Convert DOCX files to HTML and embed them in a WYSIWYG editor. This allows to edit it online, then converting it again to DOCX to lastly transform it to PDF, PNG, DOC and so on.
  • Transform PDF, DOC, ODT and RTF files to DOCX to modify their contents with phpdocx.
  • Convert DOCX files to PDF or PNG to preview it in browsers.

Additional features

Besides the features of the conversion plugin explained so far, phpdocx adds support for the following options:

  • Generate PDFs in PDF/A-1 format
  • Automatic generation of the Table of Contents (TOC)
  • Default configuration for CKEditor
  • Options to improve the final output of the documents
  • Export comments and form fields
  • Getting statistics of pages, images, tables...

For more information

Please visit the conversion plugin documentation page.