From 2a41643617cb7812839967ca48aceac6de726afe Mon Sep 17 00:00:00 2001 From: "zhaokaiyao@91isoft.com" <6922339zky> Date: Mon, 26 Jul 2021 10:10:14 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=AA=E5=9C=A8pdf=E4=B8=AD=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E6=B0=B4=E5=8D=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../adc/da/att/controller/AttFileEOController.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/adc-da-sys/src/main/java/com/adc/da/att/controller/AttFileEOController.java b/adc-da-sys/src/main/java/com/adc/da/att/controller/AttFileEOController.java index 4df99038..cc34cb29 100644 --- a/adc-da-sys/src/main/java/com/adc/da/att/controller/AttFileEOController.java +++ b/adc-da-sys/src/main/java/com/adc/da/att/controller/AttFileEOController.java @@ -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);