修复问题
This commit is contained in:
@@ -120,12 +120,6 @@
|
||||
<artifactId>javase</artifactId>
|
||||
<version>3.3.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.itextpdf</groupId>
|
||||
<artifactId>itextpdf</artifactId>
|
||||
<version>5.4.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
@@ -165,17 +159,11 @@
|
||||
<artifactId>hutool-all</artifactId>
|
||||
<version>${hutool.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.freemarker</groupId>
|
||||
<artifactId>freemarker</artifactId>
|
||||
<version>2.3.29</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.jacob</groupId>
|
||||
<artifactId>jacob</artifactId>
|
||||
<version>1.18</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.xml.bind</groupId>
|
||||
<artifactId>jaxb-api</artifactId>
|
||||
@@ -196,6 +184,25 @@
|
||||
<artifactId>activation</artifactId>
|
||||
<version>1.1.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.jacob</groupId>
|
||||
<artifactId>jacob</artifactId>
|
||||
<version>1.18</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.itextpdf</groupId>
|
||||
<artifactId>itextpdf</artifactId>
|
||||
<version>5.5.11</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.itextpdf</groupId>
|
||||
<artifactId>itext-asian</artifactId>
|
||||
<version>5.2.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.pdfbox</groupId>
|
||||
<artifactId>pdfbox</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<distributionManagement>
|
||||
|
||||
@@ -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