|
@@ -126,7 +126,8 @@ public class PdfUtil {
|
|
|
}
|
|
|
|
|
|
public static void main(String[] args) throws Exception {
|
|
|
- addPDFWaterMark("D:\\保理系统4.0数据库设计-20230627.pdf","D:\\123.pdf","12390819873409810239540723640178623");
|
|
|
+ addPDFWaterMark("D:\\Users\\wanxiangzhou\\Documents\\workspace4.7.0\\gradleFile\\fileResource\\purchaseContractSignFile\\1e6512ee-a8bb-469f-9192-4874ba29eb40.pdf",
|
|
|
+ "D:\\123.pdf","苏州轨道交通S1线09标项目部 收料人:+签署人姓名+签署人手机号:+于 当前时间 收料确认");
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -156,7 +157,7 @@ public class PdfUtil {
|
|
|
//BaseFont base = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.EMBEDDED);
|
|
|
|
|
|
PdfGState gs = new PdfGState();
|
|
|
- gs.setFillOpacity(0.2f);//图片水印透明度
|
|
|
+ gs.setFillOpacity(0.6f);//图片水印透明度
|
|
|
//gs.setStrokeOpacity(0.4f);//设置笔触字体不透明度
|
|
|
PdfContentByte content = null;
|
|
|
|
|
@@ -167,9 +168,10 @@ public class PdfUtil {
|
|
|
content = stamper.getOverContent(i+1);
|
|
|
content.setGState(gs);
|
|
|
content.beginText();//开始写入
|
|
|
- content.setFontAndSize(base, 20);//字体大小
|
|
|
+ content.setFontAndSize(base, 10);//字体大小
|
|
|
+ content.setRGBColorFill(0,0,0);
|
|
|
//showTextAligned 方法的参数(文字对齐方式,位置内容,输出水印X轴位置,Y轴位置,旋转角度)
|
|
|
- content.showTextAligned(Element.ALIGN_CENTER, word, x/3+90, y/15, 0);
|
|
|
+ content.showTextAligned(Element.ALIGN_CENTER, word, x/3+30, y/20, 0);
|
|
|
content.endText();//结束写入
|
|
|
}
|
|
|
//关闭流
|