HeightRule

HeightRule enumeration

Specifies the rule for determining the height of an object.

public enum HeightRule

Values

NameValueDescription
AtLeast0The height will be at least the specified height in points. It will grow, if needed, to accommodate all text inside an object.
Exactly1The height is specified exactly in points. Please note that if the text cannot fit inside the object of this height, it will appear truncated.
Auto2The height will grow automatically to accommodate all text inside an object.

Examples

Shows how to format rows with a document builder.

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

Table table = builder.StartTable();
builder.InsertCell();
builder.Write("Row 1, cell 1.");

// Start a second row, and then configure its height. The builder will apply these settings to
// its current row, as well as any new rows it creates afterwards.
builder.EndRow();

RowFormat rowFormat = builder.RowFormat;
rowFormat.Height = 100;
rowFormat.HeightRule = HeightRule.Exactly;

builder.InsertCell();
builder.Write("Row 2, cell 1.");
builder.EndTable();

// The first row was unaffected by the padding reconfiguration and still holds the default values.
Assert.AreEqual(0.0d, table.Rows[0].RowFormat.Height);
Assert.AreEqual(HeightRule.Auto, table.Rows[0].RowFormat.HeightRule);

Assert.AreEqual(100.0d, table.Rows[1].RowFormat.Height);
Assert.AreEqual(HeightRule.Exactly, table.Rows[1].RowFormat.HeightRule);

doc.Save(ArtifactsDir + "DocumentBuilder.SetRowFormatting.docx");

See Also