feat: 水印格式调整
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.jero.modules.system.util;
|
||||
|
||||
import com.jero.common.system.vo.LoginUser;
|
||||
import com.jero.common.util.DateUtils;
|
||||
import org.apache.pdfbox.pdmodel.PDDocument;
|
||||
import org.apache.pdfbox.pdmodel.PDPage;
|
||||
import org.apache.pdfbox.pdmodel.PDPageContentStream;
|
||||
@@ -18,6 +19,8 @@ import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 水印工具类
|
||||
@@ -47,7 +50,9 @@ public class SysWaterMarkUtil {
|
||||
if (loginUser == null) {
|
||||
return "";
|
||||
}
|
||||
return loginUser.getUsername() + loginUser.getRealname();
|
||||
Date curDate = new Date();
|
||||
String cudDateStr = DateUtils.date2Str(curDate, new SimpleDateFormat("yyyyMMddHHmmss"));
|
||||
return loginUser.getUsername() + " " + loginUser.getRealname() + " " + cudDateStr;
|
||||
}
|
||||
|
||||
public synchronized InputStream addWatermarkToPdf(InputStream inputStream) throws IOException {
|
||||
@@ -75,8 +80,8 @@ public class SysWaterMarkUtil {
|
||||
float dynamicFontSize = pageWidth * (this.fontSize / 595); // 假设基准页面宽度为595单位
|
||||
|
||||
float xStep = pageWidth / 4;
|
||||
float yStep = pageHeight / 4;
|
||||
float rotationInRadians = (float) Math.toRadians(20);
|
||||
float yStep = pageHeight / 8;
|
||||
float rotationInRadians = (float) Math.toRadians(30);
|
||||
|
||||
for (float xPosition = pageSize.getLowerLeftX(); xPosition <= pageWidth; xPosition += xStep) {
|
||||
for (float yPosition = pageSize.getLowerLeftY(); yPosition <= pageHeight; yPosition += yStep) {
|
||||
|
||||
Reference in New Issue
Block a user