水印透明度 在beginText方法后才能生效

This commit is contained in:
zhaokaiyao@91isoft.com
2021-12-15 15:16:55 +08:00
parent e35990d25f
commit 2762526260
@@ -46,16 +46,17 @@ public class WaterMarkUtil {
// 获得PDF最顶层
under = stamper.getOverContent(i);
under.saveState();
// set Transparency
PdfGState gs = new PdfGState();
// 设置透明度为0.2
gs.setFillOpacity(0.25f);
under.setGState(gs);
under.restoreState();
under.beginText();
under.setFontAndSize(base, 30);
under.setTextMatrix(30, 30);
under.setColorFill(BaseColor.LIGHT_GRAY);
// 设置透明度为0.2
// set Transparency
PdfGState gs = new PdfGState();
gs.setFillOpacity(0.2f);
under.setGState(gs);
for (int y = 0; y < 50; y++) {
for (int x = 0; x < 50; x++) {
// 水印文字成45度角倾斜 x位置 y位置 角度