/**
* @description: 合并两个PDF文件
* @return: java.lang.String
* @author: zhouhong
* @date: 2023/5/1 23:40
*/
@Override
public String mergeTwoPdfFile(MultipartFile file1, MultipartFile file2) {
try {
Document doc1 = new Document(file1.getInputStream());
Document doc2 = new Document(file2.getInputStream());
doc1.getPages().add(doc2.getPages());
String fileName = UUID.randomUUID() + ".pdf";
String filePath = ossUpLoadTools.getSavePath() + "/" + fileName;
doc1.save(filePath);
doc1.close();
File outputfile = new File(filePath);
String res = ossUpLoadTools.uploadOssFile(fileName, outputfile);
outputfile.delete();
return res;
} catch (IOException e){
e.printStackTrace();
}
return null;
}
/**
* @description: 合并对个PDF文件
* @return: java.lang.String
* @author: zhouhong
* @date: 2023/5/1 23:40
*/
@Override
public String mergeMorePdfFile(MultipartFile ... file) {
try {
String mergeFileName = UUID.randomUUID() + ".pdf";
String mergePdfPath = ossUpLoadTools.getSavePath() + "/" + mergeFileName;
String[] chilPdfPath = new String[file.length];
// 读取PDF并获取路径
for (int i = 0; i < file.length; i++) {
String fileName = UUID.randomUUID() + ".pdf";
String fileP