Individual documents we are trying to merge do not show this error , is there a reason we see this error on the merged content ?
Setting we are using to merge the document :
- Code: Select all
String[] files = {
C:\\1.docx",
"C:\\2.docx"
};
List<BlockRange> blockRanges = new ArrayList<BlockRange>();
for (int i=0 ; i< files.length; i++) {
BlockRange block = new BlockRange(WordprocessingMLPackage.load(
new File(files[i])));
blockRanges.add(block);
block.setNumberingHandler(NumberingHandler.USE_EARLIER);
block.setSectionBreakBefore(SectionBreakBefore.NEXT_PAGE);
block.setHeaderBehaviour(HfBehaviour.DEFAULT);
block.setFooterBehaviour(HfBehaviour.DEFAULT);
block.setRestartPageNumbering(false);
if (i>0) {
block.setStyleHandler(StyleHandler.RENAME_RETAIN);
}
}
// Perform the actual merge
DocumentBuilder documentBuilder = new DocumentBuilder();
WordprocessingMLPackage output = documentBuilder.buildOpenDocument(blockRanges);
SaveToZipFile saver = new SaveToZipFile(output);
saver.save("C:\\OUT_MergeWholeDocumentsUsingBlockRange.docx");