只在pdf中添加水印

This commit is contained in:
zhaokaiyao@91isoft.com
2021-07-26 10:10:14 +08:00
parent f609e3cece
commit 2a41643617
@@ -288,7 +288,19 @@ public class AttFileEOController {
WaterMarkUtil.waterMark(oldFilePath,waterFilePath,waterContent);
response.setHeader("Content-Disposition", "attachment;filename=\""+fileOldName+"\"");
response.setContentType("application/octet-stream");
File file = new File(waterFilePath);
String downloadFilePath="";
String fileName=attFileEO.getFileName();
String suffix=fileName.substring(fileName.lastIndexOf(".")+1);
//只能在pdf中添加水印,
//非pdf文件直接下载原文件
if (suffix.equals("pdf")){
downloadFilePath=waterFilePath;
}else {
downloadFilePath=oldFilePath;
}
File file = new File(downloadFilePath);
is = new FileInputStream(file);
os = response.getOutputStream();
IOUtils.copy(is, os);