[]
GcWord 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:
Access a paragraph from the paragraph collection using Paragraphs property of the RangeBase class.
Access the paragraph formatting properties using Format property of the Paragraph class.
Get border collection of the paragraph using Borders property of the ParagraphFormat class.
Get the left and right borders using Left and Right properties of the BorderCollection class respectively.
Get the border style using LineStyle property of the Border class.
Get the border color using Color property of the Border class.
Display the left and right border style and color on the console.
//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:
Access a paragraph from the paragraph collection using Paragraphs property of the RangeBase class.
Access the paragraph formatting properties using Format property of the Paragraph class.
Get border collection of the paragraph using Borders property of the ParagraphFormat class.
Get the left and right borders using Left and Right properties of the BorderCollection class respectively.
Set the border style using LineStyle property of the Border class.
Set the border color using Color property of the Border class.
//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 GcWord, see GcWord sample browser.