It is currently Thu Nov 28, 2024 1:40 am
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 10111 • Total topics 2842 • Total members 2074