Conversion plugin phpdocx
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, DOCX to PNG, DOC to DOCX...
When you transform a DOCX to other document format (PDF, HTML, DOC, ODT, RTF, PNG, TXT), the document source can be generated using phpdocx from scratch or through the replacement of placeholders in the case of templates.
Besides PDFs, it is also possible to transform documents to HTML, DOC, ODT, PNG, RTF and TXT documents, always within file type limitations.
phpdocx includes four methods to achieve the highest quality and best compatibility available:
- transformDocument: It is compatible with Linux, Windows and macOS operating systems. You can choose between OpenOffice or LibreOffice to make the conversion to PDF and other format files. This method offers perfect results in most of the cases. In some templates it will be required to perform small changes to get a satisfactory output. The conversion plugin uses this method to transform the DOCX files to PDF and other formats. Use this method to transform or get other formats such as ODT, DOC, RTF and TXT.
- transformDocAdvHTML: Native PHP classes to transform DOCX to HTML. Almost all options and methods are customizable if needed.
- transformDocUsingMSWord: It is only available for the Windows operating system. It uses the COM methods of PHP and a MS Word installation, running on Windows. The advantage of this method is that it obtains perfect results in all documents while using MS Word. The only drawback is that it forces the user to run Windows. If you have a document which transformDocument can't convert to PDF with proper quality, this is the method to achieve it.
- txt2docx: Transforms TXT files to DOCX using PHP.
- docx2txt: Transforms DOCX files to TXT using PHP.
transformDocument is the method which offers the best performance, flexibility and output quality of the four.
Although this method uses OpenOffice or LibreOffice to make the transformation, phpdocx doesn't just call these programs. Moreover, it previously prepares the document, cleans and fixes it to obtain the best possible quality in the resulting PDF file. To do that, phpdocx applies several tailor-made classes and methods.