Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
Word .NET
>
Tutorial
> Set background color
The following example shows you how to set document's background color.
C# example
using System; using Independentsoft.Office; using Independentsoft.Office.Word; namespace Program { class Program { static void Main(string[] args) { WordDocument doc = new WordDocument(); Run run1 = new Run(); run1.AddText("See background color!"); Paragraph paragraph1 = new Paragraph(); paragraph1.Add(run1); doc.Body.Add(paragraph1); Background background = new Background(); background.ThemeColor = ThemeColor.Accent5; doc.Background = background; doc.Settings.DisplayBackgroundShape = ExtendedBoolean.True; doc.Save("c:\\test\\output.docx", true); } } }
VB example
Imports System Imports Independentsoft.Office Imports Independentsoft.Office.Word Module Module1 Sub Main(ByVal args As String()) Dim doc As WordDocument = New WordDocument Dim run1 As Run = New Run run1.AddText("See background color!") Dim paragraph1 As Paragraph = New Paragraph paragraph1.Add(run1) doc.Body.Add(paragraph1) Dim background As Background = New Background background.ThemeColor = ThemeColor.Accent5 doc.Background = background doc.Settings.DisplayBackgroundShape = ExtendedBoolean.True doc.Save("c:\test\output.docx", True) End Sub End Module
Need help? Ask our developers:
Name*
Email*
Message*