It is currently Thu Dec 26, 2024 11:40 pm
WordprocessingMLPackage wordMLPackage = Docx4J.load(new File(myTemplate));
TocGenerator tocGenerator = new TocGenerator(wordMLPackage);
tocGenerator.updateToc(false);
public static void addAltChunk(R run, String html){
String chunk = "<!DOCTYPE><html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\"><head></head><body>" + html + "</body></html>";
try {
mdp.addAltChunk(AltChunkType.Xhtml, chunk.getBytes(), run);
} catch (Exception e) {
e.printStackTrace();
}
}
RelationshipsPart rp = wordMLPackage.getMainDocumentPart().getRelationshipsPart();
for (Relationship r : rp.getRelationships().getRelationship()) {
if (r.getType().equals(Namespaces.FOOTER)) {
FooterPart fp = ((FooterPart) rp.getPart(r));
// setup is a HashMap(String, String), the same one I use for the other variable replace which is working on the MainDocumentPart
fp.variableReplace(setup);
}
}
Total posts 10113 • Total topics 2844 • Total members 2075