/*** 先临时生成一个合并完成后的docx格式文档,doc会出现乱码。
*@parampathList 所有需要合并的文档的绝对路径
*@paramsavePath 一个路径,但是没有文件的后缀,之后进行拼接。
*@return状态,是否保存成功*/
public static boolean mergeWordToPdf(ListpathList, String savePath){//判断是否为pdf文件后缀的路径//String[] split = savePath.split("\\.");//if (!"pdf".equals(split[split.length-1])) {//System.out.println("请给一个以pdf保存路径结尾的路径");//return false;//}//保存合并完成后临时存放的文件
String file = savePath + ".docx";
File newfile= newFile(file);try{//判断是否存在,存在则删除
if(newfile.exists()) {
newfile.delete();
}
newfile.createNewFile();//创建一个新的doc文件
Document doc = newDocument(file);int count = 0;//进行合并
for(String filePath : pathList) {//获取文档的路径,然后合并
count++;
Document doc2= newDocument();
doc2.loadFromFile(filePath);f