I want to add a text watermark that is centered in the middle of the page and is displayed with a known point size. I can get everything working except the correct width. Here is my current code for attempting to get this working, it is based on the code in the help documentation…
Dim shape As New Aspose.Words.Drawing.Shape(_Document, Drawing.ShapeType.TextPlainText)
' Place the watermark shape in the page center
shape.WrapType = WrapType.None
shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page
shape.RelativeVerticalPosition = RelativeVerticalPosition.Page
shape.VerticalAlignment = Aspose.Words.Drawing.VerticalAlignment.Center
shape.HorizontalAlignment = Aspose.Words.Drawing.HorizontalAlignment.Center
' Show red text in Arial, 36pt
shape.StrokeColor = Colors.Red
shape.FillColor = Colors.Red
shape.TextPath.Text = "Confidential"
shape.TextPath.FontFamily = "Arial"
shape.TextPath.Size = 36
shape.Height = 36
shape.Width = (What to put here)
' Use code form help documentation to add to headers
InsertWatermarkIntoHeader(Paragraph, HeaderFooterType.HeaderPrimary)
InsertWatermarkIntoHeader(Paragraph, HeaderFooterType.HeaderFirst)
InsertWatermarkIntoHeader(Paragraph, HeaderFooterType.HeaderEven)
This works in that the text is displayed and is in the center of the page. But I do not know how to get the width correct for the known point size. I cannot use a fixed size for the shape.Width because although this example uses a fixed “Confidential” string in practice the string could be anything when I need to build the document. Any ideas?