Search code examples
javaxhtmldocxdocx4j

Docx4j - horizontal line missing while converting xhtml to docx using doc4j


I am converting xhtml to docx using doc4j. But the horizontal line that is present in xhtml is not being added to the docx. following is the snippet I am using. Can anyone please help me in fixing this?

String stringFromFile = FileUtils.readFileToString(new File(dest

                + "/" + xhtmlFile), "UTF-8");
        WordprocessingMLPackage docxOut = WordprocessingMLPackage
                .createPackage();

        NumberingDefinitionsPart ndp = new NumberingDefinitionsPart();
        docxOut.getMainDocumentPart().addTargetPart(ndp);
        ndp.unmarshalDefaultNumbering();
        XHTMLImporterImpl XHTMLImporter = new XHTMLImporterImpl(docxOut);
        XHTMLImporter.setHyperlinkStyle("Hyperlink");
        docxOut.getMainDocumentPart().getContent()
                .addAll(XHTMLImporter.convert(stringFromFile, null));

Solution

  • This commit adds support for hr, using the same Open XML as Word 2010.