I use docx4j and docx4j-ImportXHTML and faced with the issue while I need to parse html and put in a header.
public class HeaderExample {
private static ObjectFactory objectFactory = new ObjectFactory();
public static void main(String[] args) throws Exception {
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
MainDocumentPart mdp = wordMLPackage.getMainDocumentPart();
Relationship styleRel = mdp.getStyleDefinitionsPart().getSourceRelationships().get(0);
mdp.getRelationshipsPart().removeRelationship(styleRel);
Relationship relationship = createHeaderPart(wordMLPackage);
createHeaderReference(wordMLPackage, relationship);
wordMLPackage.save(new File("data/docx/Header.docx"));
}
public static Hdr getHdr(WordprocessingMLPackage wordprocessingMLPackage) throws Exception {
Hdr hdr = objectFactory.createHdr();
XHTMLImporterImpl ...