Class TextWatermark
Represents the text that appears behind the document.
Inheritance
Inherited Members
Namespace: Syncfusion.DocIO.DLS
Assembly: Syncfusion.DocIO.Base.dll
Syntax
public class TextWatermark : Watermark, IXDLSSerializable, IWidget, IParagraphItem, IEntity, IOfficeRun
Examples
The following code snippet illustrates how to add a text watermark to the Word document.
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create a new Word document
WordDocument document = new WordDocument();
//Add a section and a paragraph in the document
document.EnsureMinimal();
IWParagraph paragraph = document.LastParagraph;
paragraph.AppendText("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua");
//Create a new text watermark
TextWatermark textWatermark = new TextWatermark();
//Set the created watermark to document
document.Watermark = textWatermark;
//Set the text watermark font size
textWatermark.Size = 72;
//Set the text watermark layout to Horizontal
textWatermark.Layout = WatermarkLayout.Horizontal;
textWatermark.Semitransparent = false;
//Set the text watermark text color
textWatermark.Color = Color.Black;
//Set the text to text watermark text
textWatermark.Text = "TextWatermark";
document.Save("TextWatermark.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create a new Word document
Dim document As New WordDocument()
'Add a section and a paragraph in the document
document.EnsureMinimal()
Dim paragraph As IWParagraph = document.LastParagraph
paragraph.AppendText("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua")
'Create a new text watermark
Dim textWatermark As New TextWatermark()
'Set the text watermark to document
document.Watermark = textWatermark
'Set the text watermark font size
textWatermark.Size = 72
'Set the text watermark layout to Horizontal
textWatermark.Layout = WatermarkLayout.Horizontal
textWatermark.Semitransparent = False
'Set the text watermark text color
textWatermark.Color = Color.Black
'Set the text to the text watermark
textWatermark.Text = "TextWatermark"
document.Save("TextWatermark.docx", FormatType.Docx)
document.Close()
End Sub
Constructors
TextWatermark()
Initializes a new instance of the TextWatermark class.
Declaration
public TextWatermark()
TextWatermark(String)
Initializes a new instance of the TextWatermark class with watermark text.
Declaration
public TextWatermark(string text)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | A String that appears behind the document |
Examples
The following code snippet illustrates how to add a text watermark to the Word document.
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Template,docx");
//Create a new text watermark
TextWatermark textWatermark = new TextWatermark("Demo Text");
//Set the created watermark to document
document.Watermark = textWatermark;
document.Save("TextWatermark.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Template,docx")
'Create a new text watermark
Dim textWatermark As New TextWatermark("Demo Text")
'Set the created watermark to document
document.Watermark = textWatermark
document.Save("TextWatermark.docx", FormatType.Docx)
document.Close()
End Sub
TextWatermark(String, String, Int32, WatermarkLayout)
Initializes a new instance of the TextWatermark class with the specified watermark text, font name, font size and layout options.
Declaration
public TextWatermark(string text, string fontName, int fontSize, WatermarkLayout layout)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | A String that represents Text which appears behind the document |
System.String | fontName | A String that represents the font name for the |
System.Int32 | fontSize | A |
WatermarkLayout | layout | A WatermarkLayout represents the appearance position of the watermark text in this WordDocument |
Examples
The following code snippet illustrates how to add a text watermark to the Word document.
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument("Template,docx");
//Create a new text watermark
TextWatermark textWatermark = new TextWatermark("Demo Text", "Arial", 48, WatermarkLayout.Diagonal);
//Set the created watermark to document
document.Watermark = textWatermark;
document.Save("TextWatermark.docx", FormatType.Docx);
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into DocIO instance
Dim document As New WordDocument("Template,docx")
'Create a new text watermark
Dim textWatermark As New TextWatermark("Demo Text", "Arial", 48, WatermarkLayout.Diagonal)
'Set the created watermark to document
document.Watermark = textWatermark
document.Save("TextWatermark.docx", FormatType.Docx)
document.Close()
End Sub
Properties
Color
Gets or sets watermark text display color.
Declaration
public Color Color { get; set; }
Property Value
Type | Description |
---|---|
System.Drawing.Color | A |
FontName
Gets or sets watermark text's font name.
Declaration
public string FontName { get; set; }
Property Value
Type | Description |
---|---|
System.String | A String that represents the font name for the Text |
Remarks
Setting new value to this FontName will not auto update the width and height of the TextWatermark. Have to specify the Syncfusion.DocIO.DLS.TextWatermark.Width and Syncfusion.DocIO.DLS.TextWatermark.Height explicitly in ASP.NET Core and Xamarin platforms
Layout
Gets or sets layout for watermark text.
Declaration
public WatermarkLayout Layout { get; set; }
Property Value
Type | Description |
---|---|
WatermarkLayout | A WatermarkLayout represents the appearance position of the watermark text in this WordDocument. |
Semitransparent
Gets or sets semitransparent property for Text watermark. The default is false.
Declaration
public bool Semitransparent { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True if the watermark text appear as semitransparent; otherwise, false |
Size
Gets or sets watermark text's size.
Declaration
public float Size { get; set; }
Property Value
Type | Description |
---|---|
System.Single | A |
Remarks
Setting new value to this Size will not auto update the width and height of the TextWatermark. Have to specify the Syncfusion.DocIO.DLS.TextWatermark.Width and Syncfusion.DocIO.DLS.TextWatermark.Height explicitly in ASP.NET Core and Xamarin platforms
Text
Gets or sets watermark text.
Declaration
public string Text { get; set; }
Property Value
Type | Description |
---|---|
System.String | A String that appear behind the document. |
Methods
ReadXmlAttributes(IXDLSAttributeReader)
Reads object data from xml attributes.
Declaration
protected override void ReadXmlAttributes(IXDLSAttributeReader reader)
Parameters
Type | Name | Description |
---|---|---|
IXDLSAttributeReader | reader | The IXDLSAttributeReader object. |
Overrides
WriteXmlAttributes(IXDLSAttributeWriter)
Writes object data as xml attributes.
Declaration
protected override void WriteXmlAttributes(IXDLSAttributeWriter writer)
Parameters
Type | Name | Description |
---|---|---|
IXDLSAttributeWriter | writer | The IXDLSAttributeWriter object. |