Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Wed Sep 30, 2015 10:08 pm

I am using the following code to take a text string and add it to a PDF as a watermark.

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.

scurtiss01
 
Posts: 3
Joined: Tue Sep 08, 2015 9:37 pm

Thu Oct 01, 2015 10:09 am

Hello,

Thanks for your inquiry. Sorry that at present there is no way to do that.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy
 
Posts: 802
Joined: Mon Jan 19, 2015 6:14 am

Return to Spire.PDF