|
|
|
@ -20,13 +20,14 @@ public class WatermarkUtil {
|
|
|
|
|
|
|
|
|
|
public static Map<String,Object> getImgDefaultConfig(){
|
|
|
|
|
|
|
|
|
|
int fontSize = 48;
|
|
|
|
|
Map<String, Object> config = new HashMap<>();
|
|
|
|
|
config.put("alpha",0.5f); // 水印透明度
|
|
|
|
|
config.put("fontSize",28); // 水印文字大小
|
|
|
|
|
config.put("font",new Font("微软雅黑", Font.PLAIN, 28)); // 水印文字字体
|
|
|
|
|
config.put("fontSize",fontSize); // 水印文字大小
|
|
|
|
|
config.put("font",new Font("微软雅黑", Font.PLAIN, fontSize)); // 水印文字字体
|
|
|
|
|
config.put("color",Color.gray); // 水印文字颜色
|
|
|
|
|
config.put("xMove",80); // 水印之间的间隔
|
|
|
|
|
config.put("yMove",80); // 水印之间的间隔
|
|
|
|
|
config.put("xMove",120); // 水印之间的间隔
|
|
|
|
|
config.put("yMove",120); // 水印之间的间隔
|
|
|
|
|
config.put("degree",-40);// 旋转角度
|
|
|
|
|
config.put("formatName","JPG");
|
|
|
|
|
return config;
|
|
|
|
@ -42,8 +43,8 @@ public class WatermarkUtil {
|
|
|
|
|
}
|
|
|
|
|
config.put("fillOpacity",0.3f);// 填充透明度
|
|
|
|
|
config.put("strokeOpacity",0.4f);// 笔划不透明度
|
|
|
|
|
config.put("fontSize",16);//字体大小
|
|
|
|
|
config.put("interval",-15);// 水印间隔
|
|
|
|
|
config.put("fontSize",12);//字体大小
|
|
|
|
|
config.put("interval",-10);// 水印间隔
|
|
|
|
|
config.put("rotation",30);// 旋转角度
|
|
|
|
|
return config;
|
|
|
|
|
}
|
|
|
|
@ -85,6 +86,7 @@ public class WatermarkUtil {
|
|
|
|
|
metrics = label.getFontMetrics(label.getFont());
|
|
|
|
|
textH = metrics.getHeight();
|
|
|
|
|
textW = metrics.stringWidth(label.getText());
|
|
|
|
|
textW = textW / 2; // 手动调整宽度
|
|
|
|
|
|
|
|
|
|
PdfContentByte under;
|
|
|
|
|
int interval = (int) config.getOrDefault("interval", pdfConfig.get("interval"));
|
|
|
|
@ -98,7 +100,6 @@ public class WatermarkUtil {
|
|
|
|
|
under.beginText();
|
|
|
|
|
under.setFontAndSize(base, fontSize);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int height = interval + textH; height < pageRect.getHeight(); height = height + textH * 3) {
|
|
|
|
|
for (int width = interval + textW; width < pageRect.getWidth() + textW; width = width + textW * 2) {
|
|
|
|
|
under.showTextAligned(Element.ALIGN_LEFT
|
|
|
|
|