Converting raw html to docx
Posted: Tue Jan 08, 2013 8:38 am
My web pag takes raw html from an editor and is trying to use docx4j to convert this raw html to a docxs file. But the resulting docx file is stripped of most of it's formatting. For example all headings look the same even if they are tagged as h1,h2 or h3 they all look like an h3. Underlining is not working at all. I've tried the following:
what am I doing wrong?
- Code: Select all
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
Map<String,Style> map = StyleDefinitionsPart.getKnownStyles();
Collection<Style> col = map.values();
for(Style s : col)
{
wordMLPackage.getMainDocumentPart().getPropertyResolver().activateStyle(s);
}
wordMLPackage.getMainDocumentPart().getContent().addAll(XHTMLImporter.convert(xhtmlString.toString(), null, wordMLPackage));
what am I doing wrong?