DsWord allows you to specify the border properties for a paragraph using the Border class which can be accessed using Borders property of the ParagraphFormat class.
To get the borders of a paragraph:
C# |
Copy Code |
---|---|
//Get borders LineStyle styleLeft = doc.Body.Sections.First.GetRange().Paragraphs.Last.Format.Borders.Left.LineStyle; LineStyle styleRight = doc.Body.Sections.First.GetRange().Paragraphs.Last.Format.Borders.Right.LineStyle; Color colorLeft = doc.Body.Sections.First.GetRange().Paragraphs.Last.Format.Borders.Left.Color.RGB; Color colorRight = doc.Body.Sections.First.GetRange().Paragraphs.Last.Format.Borders.Right.Color.RGB; Console.WriteLine("Left Border: " + styleLeft + " " + colorLeft); Console.WriteLine("Right Border: " + styleRight + " " + colorRight); |
To set the borders of a paragraph:
C# |
Copy Code |
---|---|
//Set borders
doc.Body.Sections.First.GetRange().Paragraphs.Last.Format.Borders.Left.Color.RGB = Color.Red;
doc.Body.Sections.First.GetRange().Paragraphs.Last.Format.Borders.Left.LineStyle =
LineStyle.ChainLink;
doc.Body.Sections.First.GetRange().Paragraphs.Last.Format.Borders.Right.Color.RGB = Color.Yellow;
doc.Body.Sections.First.GetRange().Paragraphs.Last.Format.Borders.Right.LineStyle =
LineStyle.ChainLink; |
For more information on how to implement paragraph borders using DsWord, see DsWord sample browser.