Border

Border class

Represents a border of an object.

public class Border : InternableComplexAttr

Properties

Name Description
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 LineStyle.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.

Methods

Name Description
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[BorderType.Top];
topBorder.Color = Color.Red;
topBorder.LineWidth = 4.0d;
topBorder.LineStyle = LineStyle.DashSmallGap;

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

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

See Also