Forum


Replies: 2   Views: 2730
Preserving formatting in 'doc -> html -> docx' conversion
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  · 29-01-2016 - 02:34

Edited by Ross · 29-01-2016 - 04:26

Here is a example of the code I'm using to achieve this:

<?php
require_once 'path/phpdocx/classes/CreateDocx.inc';

$docx = new CreateDocx();

$docx->enableCompatibilityMode();

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

$html='http://www.domainexample.com/path/test.html';
$docx->embedHTML($html, array('isFile' => true));
$docx->createDocx('change/test');
?>

Everything works as intended, except the formatting is way off from the initial test.docx and final change/test.docx.

Edit: When viewing the HTML file in my browser, it actually looks like it preserves more formatting (such as indents) but those are all lost when converting it back to docx.