i want use in my document created by template some style predefined.
- Code: Select all
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage
.load(new java.io.File(inputfilepath));
// 2. Fetch the document part
StyleDefinitionsPart stylePart = wordMLPackage.getMainDocumentPart()
.getStyleDefinitionsPart();
org.docx4j.wml.Styles styles = (org.docx4j.wml.Styles) stylePart
.getJaxbElement();
for (Iterator iter = styles.getStyle().iterator(); iter.hasNext();) {
org.docx4j.wml.Style s = (org.docx4j.wml.Style) iter.next();
if (stylePart.activateStyle(s.getStyleId())) {
System.out.println("active style value: " + s.getName().getVal();
System.out.println("active styleID: " + s.getStyleId());
} else {
System.out.println("NON ACTIVE STYLE: " + s.getName().getVal()
+ " ." + s.getType());
System.out.println("NON ACTIVE STYLEID: " + s.getStyleId());
}
System.out.println("---------------------");
}
I don't understand how activate a style present in my styles list.
In StyleMappedPart i see the internal mechanism for syles...
Must i re-define a non active style avant to use??
Thanks
Fiorenzo