Bullets when converting xhtml to docx
Posted: Mon Feb 25, 2013 6:05 pm
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,
Below is the xhtml,
Please find attached output.docx file
Please help me how could i resolve this, I am using docx4j nightly build
Thanks in Advance!!!
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!!!