Hello,
I am adding water mark to a document. I am using following code. I can see the image or shape but not able to see the text of watermark. Any help will be appreciated. Following is the code.
Public Sub InsertWatermarkText(ByRef doc As Document, ByVal watermarkText As String)
' Create a watermark shape. This will be a WordArt shape.
' You are free to try other shape types as watermarks.
Dim watermark As New Shape(doc, ShapeType.Cube)
' Set up the text of the watermark.
watermark.TextPath.Size = 100
watermark.TextPath.Text = "Hello" 'watermarkText
watermark.TextPath.FontFamily = "Arial"
watermark.Width = 500
watermark.Height = 200
' Text will be directed from the bottom-left to the top-right corner.
watermark.Rotation = -40
'watermark.BehindText = False
' Remove the following two lines if you need a solid black text.
'watermark.Fill.Color = Color.Red ’ Try LightGray to get more Word-style watermark
'watermark.StrokeColor = Color.Red ’ Try LightGray to get more Word-style watermark
' Place the watermark in the page center.
watermark.RelativeHorizontalPosition = RelativeHorizontalPosition.Page
watermark.RelativeVerticalPosition = RelativeVerticalPosition.Page
watermark.WrapType = WrapType.None
watermark.VerticalAlignment = VerticalAlignment.Center
watermark.HorizontalAlignment = HorizontalAlignment.Center
watermark.ZOrder = 2
' Create a new paragraph and append the watermark to this paragraph.
Dim watermarkPara As New Paragraph(doc)
watermarkPara.AppendChild(watermark)
' Insert the watermark into all headers of each document section.
For Each sect As Section In doc.Sections
' There could be up to three different headers in each section, since we want
' the watermark to appear on all pages, insert into all headers.
InsertWatermarkIntoHeader(watermarkPara, sect, HeaderFooterType.HeaderPrimary)
InsertWatermarkIntoHeader(watermarkPara, sect, HeaderFooterType.HeaderFirst)
InsertWatermarkIntoHeader(watermarkPara, sect, HeaderFooterType.HeaderEven)
Next sect
End Sub
Private Sub InsertWatermarkIntoHeader(ByVal watermarkPara As Paragraph, ByVal sect As Section, ByVal headerType As HeaderFooterType)
Dim header As HeaderFooter = sect.HeadersFooters(headerType)
If header Is Nothing Then
' There is no header of the specified type in the current section, create it.
header = New HeaderFooter(sect.Document, headerType)
sect.HeadersFooters.Add(header)
End If
' Insert a clone of the watermark into the header.
header.AppendChild(watermarkPara.Clone(True))
End Sub