Class Background
Represents the background effects.
Implements
Inherited Members
Namespace: Syncfusion.DocIO.DLS
Assembly: Syncfusion.DocIO.Base.dll
Syntax
public class Background : XDLSSerializableBase, IXDLSSerializable
Properties
Color
Gets or sets the background color of the document.
Declaration
public Color Color { get; set; }
Property Value
Type | Description |
---|---|
System.Drawing.Color | The System.Drawing.Color specifies the background color for this document. |
Examples
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Load an existing Word document into WordDocument instance
WordDocument document = new WordDocument("Sample.docx");
//Set the background type of the document
document.Background.Type = BackgroundType.Color;
//Set the background color of the document
document.Background.Color = Color.AliceBlue;
//Save the document in the given name and format
document.Save("Document.docx", FormatType.Docx);
//Release the resources occupied by WordDocument instance
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Load an existing Word document into WordDocument instance
Dim document As New WordDocument("Sample.docx")
'Set the background type of the document
document.Background.Type = BackgroundType.Color
'Set the background color of the document
document.Background.Color = Color.AliceBlue
'Save the document in the given name and format
document.Save("Document.docx", FormatType.Docx)
'Release the resources occupied by WordDocument instance
document.Close()
End Sub
Gradient
Gets or sets the background gradient.
Declaration
public BackgroundGradient Gradient { get; set; }
Property Value
Type | Description |
---|---|
BackgroundGradient | The BackgroundGradient object that specifies the gradient effect. |
See Also
Picture
Gets or sets the background picture.
Declaration
public Image Picture { get; set; }
Property Value
Type | Description |
---|---|
System.Drawing.Image | The System.Drawing.Image that represents the background for the document. |
Examples
The following code example demonstrates how to set the background for the document.
private void Button1_Click(System.Object sender, System.EventArgs e)
{
//Create an instance of WordDocument class
WordDocument document = new WordDocument();
//Set the background type of the document
document.Background.Type = BackgroundType.Picture;
//Set the background image of the document
document.Background.Picture = Image.FromFile("Image.png");
//Add one section with one paragraph to the document
document.EnsureMinimal();
//Add the text range to the last paragraph of the section
document.LastParagraph.AppendText("Hello World!");
//Save the document in the given name and format
document.Save("Sample.docx", FormatType.Docx);
//Release the resources occupied by WordDocument instance
document.Close();
}
Private Sub button_Click(sender As Object, e As EventArgs)
'Create an instance of WordDocument class
Dim document As New WordDocument()
'Set the background type of the document
document.Background.Type = BackgroundType.Picture
'Set the background image of the document
document.Background.Picture = Image.FromFile("Image.png")
'Add one section with one paragraph to the document
document.EnsureMinimal()
'Add the text range to the last paragraph of the section
document.LastParagraph.AppendText("Hello World!")
'Save the document in the given name and format
document.Save("Sample.docx", FormatType.Docx)
'Release the resources occupied by WordDocument instance
document.Close()
End Sub
Type
Gets or sets the type of background effect.
Declaration
public BackgroundType Type { get; set; }
Property Value
Type | Description |
---|---|
BackgroundType | The BackgroundType member that specifies the type of background. |
Methods
InitXDLSHolder()
Registers child objects in XDSL holder.
Declaration
protected override void InitXDLSHolder()
Overrides
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
ReadXmlContent(IXDLSContentReader)
Reads object data from xml attributes.
Declaration
protected override bool ReadXmlContent(IXDLSContentReader reader)
Parameters
Type | Name | Description |
---|---|---|
IXDLSContentReader | reader | The IXDLSContentReader object. |
Returns
Type | Description |
---|---|
System.Boolean | The value indicating the presence of xml content. |
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. |
Overrides
WriteXmlContent(IXDLSContentWriter)
Writes object data as inside xml element.
Declaration
protected override void WriteXmlContent(IXDLSContentWriter writer)
Parameters
Type | Name | Description |
---|---|---|
IXDLSContentWriter | writer | The IXDLSContentWriter object. |