Hi,
inside a directory are some documents. These documents will be merged into a new document. Problem is, if some of the documents contains a section break then this section break is not recorded in the merged document!
I have attached the Merger.java class and the files which should be read for mergin. If you execute the main java class of the mentioned class, then it merges all files into one. You only have to adapt the paths to the directories / files in the main method for be able to find the files for reading and to write the output of the merged document where you want to be written.
I thank you very much for helping us. I am excited where the problem is, because I guess I am doing nothing wrong.
I have fixed the problem by myself! The only problem that I have now is, how to know which kind of section break the current section is? I iterate the sections like that:
private void setSectionBookmarks(Document splittedDocument) {
DocumentBuilder builder = new DocumentBuilder(splittedDocument);
int bm = 1;
for (Section section : splittedDocument.getSections()) {
if (splittedDocument.getLastSection().equals(section)) {
continue;
}
builder.moveTo(section.getBody().getLastParagraph());
builder.startBookmark(“BM_Merger_Break” + bm);
builder.endBookmark(“BM_Merger_Break” + bm);
bm++;
}
}
Then inside an other method I insert the section breaks. The problem is that I need to know in the above method the kind of section break because there exists more then only one kind like BreakType.SECTION_BREAK_CONTINUOUS.
Thanks for giving me an answer of this issue.
Best regards,
Amin
Hi Amin,
Thanks for your inquiry. It is nice to hear from you that you have solved your issue.
Regarding section break type query, I have already answered your query here in this post. Please follow that thread for further proceedings.