I'm making a program that takes an existing PDF file and modifies the security properties. I want to also be able to add a watermark to the PDF file. I've been looking into using PDFSharp to accomplish this - but I can't seem to get it to write to every page...
At present, the best I can do is get it to write the watermark to only the last page of the document using this code:
' 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)
Is it possible to tell PDFSharp to draw to every page without having to add one?
Any help much appreciated