HeightRule

Inheritance: java.lang.Object

public class HeightRule

Specifies the rule for determining the height of 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.getRowFormat();
 rowFormat.setHeight(100.0);
 rowFormat.setHeightRule(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.assertEquals(0.0d, table.getRows().get(0).getRowFormat().getHeight());
 Assert.assertEquals(HeightRule.AUTO, table.getRows().get(0).getRowFormat().getHeightRule());

 Assert.assertEquals(100.0d, table.getRows().get(1).getRowFormat().getHeight());
 Assert.assertEquals(HeightRule.EXACTLY, table.getRows().get(1).getRowFormat().getHeightRule());

 doc.save(getArtifactsDir() + "DocumentBuilder.SetRowFormatting.docx");
 

Fields

FieldDescription
AT_LEASTThe height will be at least the specified height in points.
AUTOThe height will grow automatically to accommodate all text inside an object.
EXACTLYThe height is specified exactly in points.
length

Methods

MethodDescription
fromName(String heightRuleName)
getName(int heightRule)
getValues()
toString(int heightRule)

AT_LEAST

public static int AT_LEAST

The height will be at least the specified height in points. It will grow, if needed, to accommodate all text inside an object.

AUTO

public static int AUTO

The height will grow automatically to accommodate all text inside an object.

EXACTLY

public static int EXACTLY

The height is specified exactly in points. Please note that if the text cannot fit inside the object of this height, it will appear truncated.

length

public static int length

fromName(String heightRuleName)

public static int fromName(String heightRuleName)

Parameters:

ParameterTypeDescription
heightRuleNamejava.lang.String

Returns: int

getName(int heightRule)

public static String getName(int heightRule)

Parameters:

ParameterTypeDescription
heightRuleint

Returns: java.lang.String

getValues()

public static int[] getValues()

Returns: int[]

toString(int heightRule)

public static String toString(int heightRule)

Parameters:

ParameterTypeDescription
heightRuleint

Returns: java.lang.String