use of org.docx4j.wml.SdtRun in project docx4j-template by vindell.
the class SdtFinder method printSdtContent.
public void printSdtContent(String filePath) throws Exception {
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.load(new File(filePath));
MainDocumentPart mdp = wordMLPackage.getMainDocumentPart();
Document wmlDocumentEl = (Document) mdp.getContents();
Body body = wmlDocumentEl.getBody();
SdtFinder sdtFinder = new SdtFinder();
new TraversalUtil(body, sdtFinder);
for (Child sdtChild : sdtFinder.sdtList) {
if (sdtChild instanceof SdtRun) {
SdtRun sdtRun = (SdtRun) sdtChild;
SdtPr sdtPr = sdtRun.getSdtPr();
printSdtPrContent(sdtPr);
// System.out.println(XmlUtils.marshaltoString(sdtPr, true,
// true));
SdtContent sdtContent = sdtRun.getSdtContent();
System.out.println("-----------p content=" + getContentAccessorContent(sdtContent));
} else if (sdtChild instanceof CTSdtCell) {
CTSdtCell sdtCell = (CTSdtCell) sdtChild;
SdtPr sdtPr = sdtCell.getSdtPr();
printSdtPrContent(sdtPr);
SdtContent sdtContent = sdtCell.getSdtContent();
System.out.println("-----------table content=" + getContentAccessorContent(sdtContent));
} else if (sdtChild instanceof SdtBlock) {
SdtBlock sdtBlock = (SdtBlock) sdtChild;
SdtPr sdtPr = sdtBlock.getSdtPr();
printSdtPrContent(sdtPr);
SdtContent sdtContent = sdtBlock.getSdtContent();
System.out.println("-----------sdtblock content=" + getContentAccessorContent(sdtContent));
}
}
}
use of org.docx4j.wml.SdtRun in project docx4j-template by vindell.
the class SdtFinder_2 method printSdtContent.
public void printSdtContent(String filePath) throws Exception {
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.load(new File(filePath));
MainDocumentPart mdp = wordMLPackage.getMainDocumentPart();
Document wmlDocumentEl = (Document) mdp.getContents();
Body body = wmlDocumentEl.getBody();
SdtFinder_2 sdtFinder = new SdtFinder_2();
new TraversalUtil(body, sdtFinder);
for (Child sdtChild : sdtFinder.sdtList) {
if (sdtChild instanceof SdtRun) {
SdtRun sdtRun = (SdtRun) sdtChild;
SdtPr sdtPr = sdtRun.getSdtPr();
printSdtPrContent(sdtPr);
SdtContent sdtContent = sdtRun.getSdtContent();
System.out.println("-----------p content=" + getSdtContentContent(sdtContent));
} else if (sdtChild instanceof CTSdtCell) {
CTSdtCell sdtCell = (CTSdtCell) sdtChild;
SdtPr sdtPr = sdtCell.getSdtPr();
printSdtPrContent(sdtPr);
SdtContent sdtContent = sdtCell.getSdtContent();
System.out.println("-----------table content=" + getSdtContentContent(sdtContent));
} else if (sdtChild instanceof SdtBlock) {
SdtBlock sdtBlock = (SdtBlock) sdtChild;
SdtPr sdtPr = sdtBlock.getSdtPr();
printSdtPrContent(sdtPr);
SdtContent sdtContent = sdtBlock.getSdtContent();
System.out.println("-----------sdtblock content=" + getSdtContentContent(sdtContent));
}
}
}
Aggregations