WYSIWYG DOCX editor
phpdocx Advanced and Premium licenses allow to easily create a WYSIWYG editor for DOCX documents. It is possible to transform DOCX to HTML to see it or modify it in a WYSIWYG editor and then turn it to a DOCX again.
To perform these transformations it is necessary to call two methods:
- 1- transform - available on transformDocAdvHTML: DOCX to HTML
- 2- embedHTML - available on createDocx: HTML to DOCX
Both methods use only PHP native classes, so there's no need to install additional tools.
As a practical example, let's work with a DOCX that contains texts with styles, tables, lists and images.
2- Show the HTML obtained in the previous step with any modern WYSIWYG editor like CKEditor
For the sake of the example, CKEditor works here with the standard settings. Anyway, it is possible to include more features like font sizes, preset styles, math equations… This editor and many others allow customization to add just the desired options.
3- Modify freely the contents with the WYSIWYG editor using the supported options. Then generate the DOCX with the embedHTML method
This document can be exported to PDF, DOC, ODT, RTF and other formats with the conversion plugin, or back to HTML with the aforementioned steps.
The methods reviewed here count with multiple options, detailed in its own documentation pages. Supported tags and styles are also explained there.