【发布时间】:2018-11-11 20:14:55
【问题描述】:
以下代码在pdf页面的中心添加了指定图片的水印。我希望图像在整个 pdf 页面上重复作为水印,而不是仅在中心。水印应该重复 background-repeat 属性在 css 中的工作方式。
static void Main(string[] args)
{
Document pdfDocument = new Document(@"C:\Users\code.wines\Downloads\old.pdf");
pdfDocument.Pages.Add();
ImageStamp imageStamp = new ImageStamp(@"C:\Users\code.wines\Desktop\image.jpg");
imageStamp.Background = true;
imageStamp.Height = 350;
imageStamp.Width = 350;
imageStamp.Opacity = 0.5;
imageStamp.HorizontalAlignment = HorizontalAlignment.Center;
imageStamp.VerticalAlignment = VerticalAlignment.Center;
for (int j = 1; j <= pdfDocument.Pages.Count; j++)
{
pdfDocument.Pages[j].AddStamp(imageStamp);
}
pdfDocument.Save(@"C:\Users\code.wines\Desktop\new.pdf");
}
【问题讨论】:
-
您需要获取每个页面的高度,并使用页面的 y 值将 y 轴向下移动 350 像素,直到您标记整个页面
标签: c# .net pdf watermark aspose