感谢技术大牛帮忙解决问题,小弟谢过。
两个小问题:
1,如何使用imageStamp.XIndent和imageStamp.YIndent,将水印照片放入pdf,左下角,中下,右下角等,如switch 里面。
2,如何将照片水印铺满pdf。
源文件:cc.pdf (4.0 MB)
tp.jpg (208.3 KB)
实现如下照片,中间红色框里面的不需要翻转居住就好:
QQ截图20190831224903.jpg (28.4 KB)
如下代码复制便可使用,小弟逻辑很差,大牛最好写出水印图片显示的所有位置的代码,谢谢大哥。
Document pdfDocument = new Document(cc);
ImageStamp imageStamp = new ImageStamp(tp);
String test="居中";
switch (test){
case "居中":
System.Windows.MessageBox.Show(test, "居中!");
break;
case "左上角":
System.Windows.MessageBox.Show(test, "左上角!");
break;
case "中上":
System.Windows.MessageBox.Show(test, "中上!");
break;
case "右上角":
System.Windows.MessageBox.Show(test, "右上角!");
break;
case "左下角":
System.Windows.MessageBox.Show(test, "左下角!");
break;
case "左中":
System.Windows.MessageBox.Show(test, "左中!");
break;
case "右中":
System.Windows.MessageBox.Show(test, "右中!");
break;
case "中下":
System.Windows.MessageBox.Show(test, "中下!");
break;
case "右下角":
System.Windows.MessageBox.Show(test, "右下角!");
break;
}
imageStamp.Background = false;
imageStamp.Height = 300;
imageStamp.Width = 300;
//imageStamp.Rotate = Rotation.on270;
//旋转角度
//imageStamp.RotateAngle = XzJD;
//透明度 0.1-0.8
imageStamp.Opacity = 0.5;
/*imageStamp.XIndent = (pdfDocument.PageInfo.Width / 2) - (imageStamp.Width / 2);
imageStamp.YIndent = (pdfDocument.PageInfo.Height / 2) - (imageStamp.Height / 2);*/
for (int i=1;i<= pdfDocument.Pages.Count;i++) {
pdfDocument.Pages[i].AddStamp(imageStamp);
}
//save output document
pdfDocument.Save("ImageStamp_output45.pdf");