Border

Border class

Represents a border of an object.

To learn more, visit the Programming with Documents documentation article.

public class Border : InternableComplexAttr

Properties

NameDescription
Color { get; set; }Gets or sets the border color.
DistanceFromText { get; set; }Gets or sets distance of the border from text or from the page edge in points.
IsVisible { get; }Returns true if the LineStyle is not None.
LineStyle { get; set; }Gets or sets the border style.
LineWidth { get; set; }Gets or sets the border width in points.
Shadow { get; set; }Gets or sets a value indicating whether the border has a shadow.
ThemeColor { get; set; }Gets or sets the theme color in the applied color scheme that is associated with this Border object.
TintAndShade { get; set; }Gets or sets a double value that lightens or darkens a color.

Methods

NameDescription
ClearFormatting()Resets border properties to default values.
Equals(Border)Determines whether the specified border is equal in value to the current border.
override Equals(object)Determines whether the specified object is equal in value to the current object.
override GetHashCode()Serves as a hash function for this type.

Remarks

Borders can be applied to various document elements including paragraph, run of text inside a paragraph or a table cell.

Examples

Shows how to insert a string surrounded by a border into a document.

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

builder.Font.Border.Color = Color.Green;
builder.Font.Border.LineWidth = 2.5d;
builder.Font.Border.LineStyle = LineStyle.DashDotStroker;

builder.Write("Text surrounded by green border.");

doc.Save(ArtifactsDir + "Border.FontBorder.docx");

Shows how to insert a paragraph with a top border.

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

Border topBorder = builder.ParagraphFormat.Borders.Top;
topBorder.LineWidth = 4.0d;
topBorder.LineStyle = LineStyle.DashSmallGap;
// Set ThemeColor only when LineWidth or LineStyle setted.
topBorder.ThemeColor = ThemeColor.Accent1;
topBorder.TintAndShade = 0.25d;

builder.Writeln("Text with a top border.");

doc.Save(ArtifactsDir + "Border.ParagraphTopBorder.docx");

See Also