|
|
|
|
@ -468,6 +468,8 @@ public class img2PdfUtil {
|
|
|
|
|
PdfStamper stamper = null;
|
|
|
|
|
try {
|
|
|
|
|
reader = new PdfReader(bos.toByteArray());
|
|
|
|
|
// PDF总页数
|
|
|
|
|
int total = reader.getNumberOfPages();
|
|
|
|
|
// 加完水印的文件
|
|
|
|
|
if (null != response) {
|
|
|
|
|
stamper = new PdfStamper(reader, response.getOutputStream());
|
|
|
|
|
@ -476,8 +478,7 @@ public class img2PdfUtil {
|
|
|
|
|
}
|
|
|
|
|
// 设置字体
|
|
|
|
|
BaseFont font = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.EMBEDDED);
|
|
|
|
|
// PDF总页数
|
|
|
|
|
int total = reader.getNumberOfPages() + 1;
|
|
|
|
|
|
|
|
|
|
// 循环对每页插入水印
|
|
|
|
|
PdfContentByte content;
|
|
|
|
|
PdfGState gs = new PdfGState();
|
|
|
|
|
@ -523,17 +524,17 @@ public class img2PdfUtil {
|
|
|
|
|
// 底部水印
|
|
|
|
|
content.endText();
|
|
|
|
|
//第二水印
|
|
|
|
|
content.beginText();
|
|
|
|
|
//content.beginText();
|
|
|
|
|
//16进制颜色转color
|
|
|
|
|
content.setColorFill(color);
|
|
|
|
|
//content.setColorFill(color);
|
|
|
|
|
// 设置字体及字号
|
|
|
|
|
content.setFontAndSize(font, textSize);
|
|
|
|
|
//content.setFontAndSize(font, textSize);
|
|
|
|
|
// 设置起始位置
|
|
|
|
|
content.setTextMatrix(textX, textY);
|
|
|
|
|
//content.setTextMatrix(textX, textY);
|
|
|
|
|
// 中间水印
|
|
|
|
|
content.showTextAligned(Element.ALIGN_LEFT, text, textX, textY, textRotation);
|
|
|
|
|
//content.showTextAligned(Element.ALIGN_LEFT, text, textX, textY, textRotation);
|
|
|
|
|
// 底部水印
|
|
|
|
|
content.endText();
|
|
|
|
|
//content.endText();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch (IOException | DocumentException e) {
|
|
|
|
|
|