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的頁面,而不是我添加的頁面? –
你下載了完整的示例並試用了嗎?水印示例修改現有頁面,將其檢出。 –