diff --git a/jero-boot/jero-boot-module-system/pom.xml b/jero-boot/jero-boot-module-system/pom.xml
index 2b4a19c1f..7b1159b4f 100644
--- a/jero-boot/jero-boot-module-system/pom.xml
+++ b/jero-boot/jero-boot-module-system/pom.xml
@@ -27,6 +27,16 @@
false
+
+ com.e-iceblue
+ e-iceblue
+ http://repo.e-iceblue.com/nexus/content/groups/public/
+
+
+ public
+ aliyun nexus
+ http://maven.aliyun.com/nexus/content/groups/public/
+
@@ -65,7 +75,19 @@
org.springframework.cloud
spring-cloud-openfeign-core
+
+ com.lowagie
+ itext
+ 4.2.1
+
+
+
+ e-iceblue
+ spire.doc.free
+ 2.0.0
+ compile
+
-
\ No newline at end of file
+
diff --git a/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/system/controller/CommonController.java b/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/system/controller/CommonController.java
index 80a66efb6..46d39cbda 100644
--- a/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/system/controller/CommonController.java
+++ b/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/system/controller/CommonController.java
@@ -3,16 +3,19 @@ package com.jero.modules.system.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.jero.common.api.vo.Result;
+import com.jero.common.constant.CommonConstant;
import com.jero.common.exception.JeroBootException;
-import com.jero.common.util.*;
+import com.jero.common.system.api.ISysBaseAPI;
+import com.jero.common.util.RestUtil;
+import com.jero.common.util.TokenUtils;
+import com.jero.common.util.oConvertUtils;
import com.jero.modules.oss.entity.OSSFile;
import com.jero.modules.oss.service.IOSSFileService;
+import com.jero.modules.system.util.PDFUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
-import com.jero.common.api.vo.Result;
-import com.jero.common.constant.CommonConstant;
-import com.jero.common.system.api.ISysBaseAPI;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@@ -21,8 +24,12 @@ import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.http.server.ServletServerHttpRequest;
import org.springframework.util.AntPathMatcher;
-import org.springframework.util.FileCopyUtils;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.HandlerMapping;
@@ -31,7 +38,12 @@ import org.springframework.web.servlet.ModelAndView;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import java.io.*;
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
import java.net.URLDecoder;
import java.util.List;
@@ -378,7 +390,7 @@ public class CommonController {
}
/**
- * 文件预览
+ * 文件预览PDF
*
* @param id 传入文件id
* @param request
@@ -400,13 +412,19 @@ public class CommonController {
//本地下载
String filePath = ossFile.getUrl();
File file = new File(filePath);
+ //水印内容
+ String waterContent = "water mark";//临时定义(水印信息通过传过来)
+ File newFile = PDFUtils.PDFWatermark(file,waterContent);
+ String path = newFile.getPath();
+// String substring = path.substring(filePath.length(), path.length());
+
if(!file.exists()){
response.setStatus(404);
throw new RuntimeException("文件不存在..");
}
// 文件名称
fileName = file.getName();
- inputStream = new BufferedInputStream(new FileInputStream(filePath));
+ inputStream = new BufferedInputStream(new FileInputStream(path));
response.addHeader("Content-Disposition", "attachment;fileName=" + new String(fileName.getBytes("UTF-8"),"iso-8859-1"));
response.setContentType("application/force-download");// 设置强制下载不打开
outputStream = response.getOutputStream();
diff --git a/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/system/util/PDFUtils.java b/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/system/util/PDFUtils.java
new file mode 100644
index 000000000..8b974fb56
--- /dev/null
+++ b/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/system/util/PDFUtils.java
@@ -0,0 +1,170 @@
+package com.jero.modules.system.util;
+
+import com.spire.pdf.*;
+import com.spire.pdf.graphics.*;
+import java.awt.*;
+import java.awt.geom.*;
+import java.io.*;
+
+public class PDFUtils {
+ public static void main(String[] args) throws IOException {
+ File file = new File("E:\\DeskTop\\动态资料\\加入IEEE会员 - 副本 - 副本.pdf");
+ InputStream in = new FileInputStream(file) ;
+// byte[] byteArray=File2byte(new File("f:ceshi/1.pdf"));
+ //创建PdfDocument类的对象
+ PdfDocument pdf = new PdfDocument();
+ //加载测试文档
+ pdf.loadFromStream(in);
+ try {
+ pdf.getPages().add();
+ }catch (Exception e){
+ e.printStackTrace();
+ }
+
+
+ //获取测试文档中的第一页
+ for(int i=0; i