- Code: Select all
Public Shared Sub InsertWatermark(ByVal page As PdfPageBase, ByVal watermark As String)
Dim brush As New PdfTilingBrush(New SizeF(page.Canvas.ClientSize.Width / 2, page.Canvas.ClientSize.Height / 3))
brush.Graphics.SetTransparency(0.3F)
brush.Graphics.Save()
brush.Graphics.TranslateTransform(brush.Size.Width / 2, brush.Size.Height / 2)
brush.Graphics.RotateTransform(-45)
brush.Graphics.DrawString(watermark, New PdfFont(PdfFontFamily.Helvetica, 24), PdfBrushes.Violet, 0, 0, New PdfStringFormat(PdfTextAlignment.Center))
brush.Graphics.Restore()
brush.Graphics.SetTransparency(1)
page.Canvas.DrawRectangle(brush, New RectangleF(New PointF(0, 0), page.Canvas.ClientSize))
End Sub
It appears that the string is converted to a graphic image and is no longer stored in the PDF file as text.
Is there a method to examine the watermark and convert it back to text or maybe return the bytes that make up the image? I am trying to accomplish a task of sorting through many PDFs and sorting out only PDFs with a specific watermark.