0
我正在制作一个程序,它接受现有PDF文件并修改安全属性。我想也能够在PDF文件中添加水印。我一直在寻找使用PDFsharp来实现这一点 - 但我似乎无法得到它写入每一个页面...使用PDFsharp将水印添加到现有页面
目前,我能做的最好的就是让它只写水印使用此代码的文档的最后一页:
' Create an empty page
Dim page As PdfPage = document.AddPage
page.Orientation = PageOrientation.Landscape
page.Size = PageSize.A4
' Get an XGraphics object for drawing
Dim gfx As XGraphics = XGraphics.FromPdfPage(page, XGraphicsPdfPageOptions.Prepend)
Dim tf As Layout.XTextFormatter = New Layout.XTextFormatter(gfx)
' Create a font
Dim font As XFont = New XFont("Verdana", 20, XFontStyle.Bold)
' Draw the text
gfx.DrawString("WATERMARK", font, XBrushes.Red, _
New XRect(0, 0, page.Width.Point, page.Height.Point), XStringFormats.Center)
是否可以告诉PDFsharp无需添加一张即可绘制到每个页面?
任何帮助非常感谢:)
我发现的所有水印都包含标识符“page”。如何将其设置为现有PDF的页面,而不是我添加的页面? –
你下载了完整的示例并试用了吗?水印示例修改现有页面,将其检出。 –