Page 1 of 1

Bullets when converting xhtml to docx

PostPosted: Mon Feb 25, 2013 6:05 pm
by pritesh.shah17
Hello All,

I am trying to convert xhtml to docx.
My xHtml contains table and inside there are <ul <li, so when I convert it docx, bullets are not getting formatted properly.

Below is the test code for converting xhtml to docx,
Code: Select all
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();

        AlternativeFormatInputPart afiPart = new AlternativeFormatInputPart(AltChunkType.Xhtml);
        afiPart.setBinaryData(html.getBytes("UTF-8"));
        afiPart.setContentType(new ContentType("application/xhtml+xml"));
        Relationship altChunkRel = wordMLPackage.getMainDocumentPart().addTargetPart(afiPart);
        // .. the bit in document body
        CTAltChunk ac = Context.getWmlObjectFactory().createCTAltChunk();
        ac.setId(altChunkRel.getId());
        wordMLPackage.getMainDocumentPart().addObject(ac);
        wordMLPackage.getContentTypeManager().addDefaultContentType("xhtml", "application/xhtml+xml");

        // CONVERTING ALTCHUNKS
        WordprocessingMLPackage pkgOut = wordMLPackage.getMainDocumentPart().convertAltChunks();
        pkgOut.save(new java.io.File("C:\\Users\\priteshs\\Desktop\\Test\\" + "input.doc"));
        System.out.println(XmlUtils.marshaltoString(pkgOut.getMainDocumentPart().getJaxbElement(), true, true));

Below is the xhtml,
Code: Select all
<html>
    <head>
        <title>roses</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
       
    </head>

    <body>
     
       
       <div id="textual-notes">
          <h4>Textual Notes</h4>
          <ul>
                   <li>W1: rose2 - This is the base text.</li>
                   <li>W2: rose1</li>
          </ul>
       </div>
     
       
    </body>
</html>


Please find attached output.docx file

Please help me how could i resolve this, I am using docx4j nightly build

Thanks in Advance!!!

Re: Bullets when converting xhtml to docx

PostPosted: Mon Feb 25, 2013 6:54 pm
by jason
There seems to be a fair bit of demand for improvements to XHTML import, so I will look at this again sooner or later.

But don't hold your breath!

If you need a fix in the short term, your options are to develop a patch yourself, or to pay someone to do it for you, in which case you might post in the new marketplace forum: marketplace-f18/

Sorry I can't be of more help right now.