Class TextWatermark
Represents the text that appears behind the document.
Inheritance
Inherited Members
Namespace: Syncfusion.DocIO.DLS
Assembly: Syncfusion.DocIO.Portable.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(String, String, Single, Single)
Initializes a new instance of the TextWatermark class with the specified watermark text, font name, width and height options.
Declaration
public TextWatermark(string text, string fontName, float width, float height)
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.Single | width | A float that represents Widthwhich is the width of watermark. |
System.Single | height | A float that represents Heightwhich is the height of watermark. |
Examples
The following code snippet illustrates how to add a text watermark to the Word document.
//Load an existing Word document into DocIO instance
WordDocument document = new WordDocument();
document.EnsureMinimal();
//Create a new text watermark
TextWatermark textWatermark = new TextWatermark("Demo Text", "Arial", 234, 468);
//Set the created watermark to document
document.Watermark = textWatermark;
FileStream file = new FileStream("WaterMarkSample.docx", FileMode.Create);
document.Save(file, FormatType.Docx);
document.Close();
'Load an existing Word document into DocIO instance
Dim document As New WordDocument()
document.EnsureMinimal()
'Create a new text watermark
Dim textWatermark As New TextWatermark("Demo Text", "Arial", 234, 468)
'Set the created watermark to document
document.Watermark = textWatermark
Dim file As New FileStream("WaterMarkSample.docx", FileMode.Create)
document.Save(file, FormatType.Docx)
document.Close()
Properties
Color
Gets or sets watermark text display color.
Declaration
public Color Color { get; set; }
Property Value
Type | Description |
---|---|
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 Width and Height explicitly in ASP.NET Core and Xamarin platforms
Height
Gets or sets watermark text's height.
Declaration
public float Height { get; set; }
Property Value
Type | Description |
---|---|
System.Single | A |
Remarks
Height is only applicable for ASP.NET Core and Xamarin platforms.
Item[Int32]
Gets or sets the key in property collection.
Declaration
protected object this[int key] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | key | The integer that specifies the key. |
Property Value
Type | Description |
---|---|
System.Object | An object that specifies the key. |
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 Width and 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. |
Width
Gets or sets watermark text's width.
Declaration
public float Width { get; set; }
Property Value
Type | Description |
---|---|
System.Single | A |
Remarks
Width is only applicable for ASP.NET Core and Xamarin platforms.
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. |