is there a way to go from a xhtml file to docx so that the Table Headers repeat to multiple pages?
My current implementation of the xhtml importer seems to strip the <thead> and <tbody> tags while doing the conversion.
- Code: Select all
ImportXHTMLProperties.setProperty("docx4j-ImportXHTML.Element.Heading.MapToStyle", true);
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage(PageSizePaper.LETTER, false);
// Settings Styles and Numberings from Template to new Docx
StyleDefinitionsPart stylesPart = new StyleDefinitionsPart();
stylesPart.setContents(getStyleFromDocx(templateName).getContents());
wordMLPackage.getMainDocumentPart()
.addTargetPart(stylesPart);
NumberingDefinitionsPart numberingPart = new NumberingDefinitionsPart();
numberingPart.setContents(getNumberingFromDocx(templateName).getContents());
wordMLPackage.getMainDocumentPart()
.addTargetPart(numberingPart);
// Creating new Docx
XHTMLImporterImpl XHTMLImporter = new XHTMLImporterImpl(wordMLPackage);
XHTMLImporter.setHyperlinkStyle("Hyperlink");
String htmlc = new String(Files.readAllBytes(Paths.get(RMEnvironment.getRMTempFolder()+"/output.html")));
wordMLPackage.getMainDocumentPart()
.getContent()
.addAll(XHTMLImporter.convert(htmlc, null));
TransformerFactory factory = TransformerFactory.newInstance();
DOMResult result = new DOMResult();
Templates templates = factory
.newTemplates(new StreamSource(new FileInputStream(RMEnvironment.getRMTempFolder()+"/docxconf/noFormatting.xslt")));
wordMLPackage.getMainDocumentPart()
.transform(templates, null, result);
org.w3c.dom.Document domDoc = (org.w3c.dom.Document) result.getNode();
wordMLPackage.getMainDocumentPart()
.setContents(wordMLPackage.getMainDocumentPart()
.unmarshal(domDoc.getDocumentElement()));