Forum


Replies: 4   Views: 4550
Coversion back to docx from html file generated by plugin 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 tarzip  · 21-06-2013 - 09:16

Hi



We recently bought corp verson expecting it to convert docx to html and also html to docx but now realised that it is one way conversion.



Is it possible to convert back to docx document from the html files genrated by plugin?



 



 



Thanks



 


Posted by jorgelj  · 24-06-2013 - 09:01

Hello,



You can do both tasks. To transform DOCX to HTML you need to use the conversion plugin and to transform HTML to DOCX you need to use embedHTML.



Regards. Jorge.


Posted by tarzip  · 03-07-2013 - 08:47

Thanks for reply.



I was able to convert to docx back but there are 2 smal issues.



Conversion si adding line extra breaks in formatting for some content. Another issue is that headers and footer don't get added back as header and footer but as image at top and bottom only.



I see that there is <DIV TYPE=HEADER> and <DIV TYPE=FOOTER> in html file generated.



Is it possible somehow to insert them as actual header and footer in docx when converting from html?



Thanks.


Posted by jorgelj  · 04-07-2013 - 12:23

Hello,



As HTML doesn't have headers and footers like DOCX, you'll need to write the code to create the headers and footers of that HTML. You just need to use embedHTML to add HTML to DOCX to content, header or footer with 'target' option. Please check included phpdoc:



/**

     * Embed HTML into the Word document by parsing the HTML code and converting it into WordML

     * It preserves many CSS styles

     *

     * @access public

     * @example ../examples/easy/EmbedSimpleHTML.php

     * @example ../examples/intermediate/EmbedExternalHTML.php

     * @example ../examples/intermediate/EmbedHTMLinTable.php

     * @param string $html HTML to add. Must be a valid XHTML

     * @param array $options:

     * isFile (boolean),

     * baseURL (string),

     * downloadImages (boolean),

     * filter (string) could be an string denoting the id, class or tag to be filtered.

     * If you want only a class introduce .classname, #idName for an id or <htmlTag> for a particular tag. One can also use

     * standard XPath expresions supported by PHP.

     * 'parseAnchors' (boolean),

     * 'parseDivs' (paragraph, table): parses divs as paragraphs or tables,

     * 'parseFloats' (boolean),

     * 'strictWordStyles' (boolean) if true ignores all CSS styles and uses the styles set via the wordStyles option (see next)

     * 'wordStyles' (array) associates a particular class, id or HTML tag to a Word style

     * 'target' (string) document (default value), defaultHeader, firstHeader, evenHeader, defaultFooter, firstFooter, evenFooter.

     * 'rawWordML' (boolean)

     */

    public function embedHTML($html = '<html><body></body></html>', $options = array())



Regards.