修复问题
This commit is contained in:
@@ -10,8 +10,11 @@ import com.jacob.com.Dispatch;
|
||||
import freemarker.template.Configuration;
|
||||
import freemarker.template.Template;
|
||||
import freemarker.template.Version;
|
||||
import org.apache.pdfbox.io.MemoryUsageSetting;
|
||||
import org.apache.pdfbox.multipdf.PDFMergerUtility;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -205,4 +208,28 @@ public class WordConvertUtils {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* pdf合并
|
||||
*
|
||||
* @param files 源文件的相对路径 例:["D:\anrui\upload\template\pdf\111.pdf","D:\anrui\upload\template\222.pdf"]
|
||||
* @param targetPath 输出的pdf的路径 D:\anrui\upload\template\pdf\333.pdf
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static File mulFile2One(List<File> files, String targetPath) throws Exception {
|
||||
PDFMergerUtility mergePdf = new PDFMergerUtility();
|
||||
for (File f : files) {
|
||||
if (f.exists() && f.isFile()) {
|
||||
// 循环添加要合并的pdf
|
||||
mergePdf.addSource(f);
|
||||
}
|
||||
}
|
||||
// 设置合并生成pdf文件名称
|
||||
mergePdf.setDestinationFileName(targetPath);
|
||||
// 合并pdf
|
||||
mergePdf.mergeDocuments(MemoryUsageSetting.setupMainMemoryOnly());
|
||||
//ToDo:根据需求实现是否要删除源文件
|
||||
return new File(targetPath);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user