Hi,
- // to keep only sections that aren’t annexes in the templatedoc
- ArrayList<Section> templateDocSections = new ArrayList<Section>();
- for (Section section : doc.getSections()) {
- String sectionTitle;
- sectionTitle = findSectionTitle(section);
- if (sectionTitle != null) {
- DocumentBuilder dbTemp = new DocumentBuilder(newDoc);
- newDoc.getSections().get(0).appendContent((Section)
- newDoc.importNode(section, true, ImportFormatMode.KEEP_SOURCE_FORMATTING));
- /*
- Paragraph currentParagraph = dbTemp.getCurrentParagraph();
- if (currentParagraph.getText().trim().isEmpty()){
- currentParagraph.remove();
- }
- /
- if (sectionTitle == null || sectionTitle.isEmpty()) {
- }
- dbTemp.moveToDocumentStart();
- dbTemp.writeln(“heya”);
- newDoc.save(“D:\docx_test\break\” + sectionTitle + “.docx”, SaveFormat.DOCX);
- } else {
- templateDocSections.add(section);
- }
- }