Aspose.words合并多个word

1、下载aspose.words的jar包,导入aspose.words依赖


	com.aspose
	aspose-words
	15.8.0
	system
	${project.basedir}/lib/aspose-words-15.8.0-jdk16.jar

2、去除水印

public boolean isLence() {
		try {
			InputStream is = HzbsSignTemplaceServiceImpl.class.getClassLoader()
					.getResourceAsStream("license.xml");
			License aposeLic = new License();
			aposeLic.setLicense(is);
			return true;
		} catch (Exception e) {
			return false;
		}
	}

license.xml内容


  
    
      Aspose.Total for Java
      Aspose.Words for Java
    
    Enterprise
    20991231
    20991231
    23dcc79f-44ec-4a23-be3a-03c1632404e9
  
  0nRuwNEddXwLfXB7pw66G71MS93gW8mNzJ7vuh3Sf4VAEOBfpxtHLCotymv1PoeukxYe31K441Ivq0Pkvx1yZZG4O1KCv3Omdbs7uqzUB4xXHlOub4VsTODzDJ5MWHqlRCB1HHcGjlyT2sVGiovLt0Grvqw5+QXBuinoBY0suX0=

3、合并文档


if (!this.isLence()) {
	throw new CustomException("去水印失败,请联系管理员");
}
try{
   //将cs1.doc和cs2.doc合并到cs3.doc中
   Document doc1 = new Document("d:\cs1.doc");
   Document doc2 = new Document("d:\cs2.doc");
   Document doc3 = new Document();
   FileOutputStream fos = new FileOutputStrem(new File("d:\cs3.doc"));
   doc3.removeAllChildren();
   doc3.appendDocument(doc1,ImportFormatMode.USE_DESTINATION_STYLES);
   doc3.appendDocument(doc2,ImportFormatMode.USE_DESTINATION_STYLES);
   doc3.save(fos, SaveFormat.DOC);
}catch(Exception e){
   throw new CustomException(e.getMessage());
}

你可能感兴趣的:(doc,aspose,java)