我想做一个在PDF上加水印,但PDF页面有横放还有竖放无法确认其绝到位置,代码如下:
dfReader reader = new PdfReader("aaa.pdf");
PdfStamper stamp = new PdfStamper(reader,new FileStream("ccc.pdf",FileMode.Create));
int pageSize = reader.NumberOfPages;
Image img = Image.GetInstance("LOGO.png");
img.SetAbsolutePosition(600,50);//水印位置,想放到下面动态确认
for(int i = 1; i <= pageSize; i++) {
PdfContentByte under = stamp.GetOverContent(i);
//img.SetAbsolutePosition(600,50); 依据页面生成X,Y坐标
under.AddImage(img);
}
stamp.Close();// 关闭