String path = "C:\\Users\\z_jia\\Desktop\\a\\DMS\\";
Document word = new Document(path + "a.docx");
Document coverWord = new Document(path + "封面0116.docx");
Document target = (Document) word.deepClone(false);
target.appendDocument(coverWord, ImportFormatMode.USE_DESTINATION_STYLES);
target.appendDocument(word, ImportFormatMode.USE_DESTINATION_STYLES);
word = target;
word.save(path + "output.docx", SaveFormat.DOCX);
I want to merge two documents and keep the a.docx format, I used the above codes.
but the results :
封面0116.docx (18.9 KB)
a.docx (2.9 MB)
output.docx (2.9 MB)