Forum


Replies: 4   Views: 4356
Converting docx to html
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 Ross  · 21-01-2016 - 19:38

I'm having issues creating an html file from a docx file.  I'm copying the example from http://www.phpdocx.com/api-documentation/format-conversion/convert-Word-docx-into-pdf-with-PHP. My code is 100% identical, except I'm converting it to .html.  This is the only difference in my code:

$docx->transformDocument('example_text.docx', 'example_text.html');

When this runs, the example_text.docx file is created as expected, but example_text.html is not.

Any ideas why this may be failing?

Posted by Ross  · 21-01-2016 - 19:43

I should also note that it won't convert to any format.  Trying to convert to example_text.pdf for example does not work as well.  No target file is generated.

Posted by admin  · 22-01-2016 - 08:43

Hello,

UPDATE: phpdocx 8 added DOCX to HTML native conversion:

https://www.phpdocx.com/documentation/introduction/word-to-html-PHP

Are you using the plugin based on OpenOffice or LibreOffice?

Please follow the instructions available on (http://www.phpdocx.com/documentation/conversion-plugin) to debug it.

The most common error is rw access to the temp folder access of any of both programs.

Regards.

Posted by Ross  · 28-01-2016 - 20:06

Hi, I am using Open Office.  

Following the debug instructions, I ran the script with debug and got this back:

[INFO][/tmp/tempDocX_56aa7359acbda.docx] Converting tempDocX_56aa7359acbda.docx into tempOdt_56aa7359ae2fe.odt
progress:w:pPrprogress:w:rPrprogress:w:pPrprogress:w:pPrprogress:w:pPrprogress:w:pPrprogress:w:pprogress:w:rprogress:w:tprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:styleprogress:w:style[INFO][/tmp/tempDocX_56aa7359acbda.docx] Conversion succeeded
[INFO][/tmp/tempDocX_56aa7359acbda.docx] Total conversion time: 00:00:00.9641689
Done.
Jan 28, 2016 3:00:27 PM com.artofsolving.jodconverter.openoffice.connection.AbstractOpenOfficeConnection connect
INFO: connected
Jan 28, 2016 3:00:29 PM com.artofsolving.jodconverter.openoffice.connection.AbstractOpenOfficeConnection disposing
INFO: disconnected
Exception in thread "main" com.artofsolving.jodconverter.openoffice.connection.OpenOfficeException: conversion failed: could not load input document
        at com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter.loadAndExport(OpenOfficeDocumentConverter.java:134)
        at com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter.convertInternal(OpenOfficeDocumentConverter.java:120)
        at com.artofsolving.jodconverter.openoffice.converter.AbstractOpenOfficeDocumentConverter.convert(AbstractOpenOfficeDocumentConverter.java:104)
        at com.artofsolving.jodconverter.openoffice.converter.AbstractOpenOfficeDocumentConverter.convert(AbstractOpenOfficeDocumentConverter.java:74)
        at com.artofsolving.jodconverter.openoffice.converter.AbstractOpenOfficeDocumentConverter.convert(AbstractOpenOfficeDocumentConverter.java:70)
        at com.artofsolving.jodconverter.cli.ConvertDocument.convertOne(ConvertDocument.java:154)
        at com.artofsolving.jodconverter.cli.ConvertDocument.main(ConvertDocument.java:133)

Any ideas?

Posted by Ross  · 28-01-2016 - 23:21

You can ignore this.  I switched to LibreOffice and everything seems to work fine.