com.aspose.words

Class HeightRule

  • java.lang.Object
    • com.aspose.words.HeightRule
public class HeightRule 
extends java.lang.Object

Utility class containing constants. Specifies the rule for determining the height of an object.

Example:

Shows how to build a nice bordered table.
DocumentBuilder builder = new DocumentBuilder();

// Start building a table.
builder.startTable();

// Set the appropriate paragraph, cell, and row formatting. The formatting properties are preserved
// until they are explicitly modified so there's no need to set them for each row or cell.

builder.getParagraphFormat().setAlignment(ParagraphAlignment.CENTER);

builder.getCellFormat().clearFormatting();
builder.getCellFormat().setWidth(300);
builder.getCellFormat().setVerticalAlignment(CellVerticalAlignment.CENTER);
builder.getCellFormat().getShading().setBackgroundPatternColor(new Color(173, 255, 47)); //"green-yellow"
builder.getCellFormat().setWrapText(false);
builder.getCellFormat().setFitText(true);

builder.getRowFormat().clearFormatting();
builder.getRowFormat().setHeightRule(HeightRule.EXACTLY);
builder.getRowFormat().setHeight(50);
builder.getRowFormat().getBorders().setLineStyle(LineStyle.ENGRAVE_3_D);
builder.getRowFormat().getBorders().setColor(new Color(255, 165, 0)); // "orange"

builder.insertCell();
builder.write("Row 1, Col 1");

builder.insertCell();
builder.write("Row 1, Col 2");

builder.endRow();

// Remove the shading (clear background).
builder.getCellFormat().getShading().clearFormatting();

builder.insertCell();
builder.write("Row 2, Col 1");

builder.insertCell();
builder.write("Row 2, Col 2");

builder.endRow();

builder.insertCell();

// Make the row height bigger so that a vertically oriented text could fit into cells.
builder.getRowFormat().setHeight(150);
builder.getCellFormat().setOrientation(TextOrientation.UPWARD);
builder.write("Row 3, Col 1");

builder.insertCell();
builder.getCellFormat().setOrientation(TextOrientation.DOWNWARD);
builder.write("Row 3, Col 2");

builder.endRow();

builder.endTable();

builder.getDocument().save(getArtifactsDir() + "DocumentBuilder.InsertTable.doc");

Field Summary
static final intAT_LEAST = 0
The height will be at least the specified height in points. It will grow, if needed, to accommodate all text inside an object.
static final intEXACTLY = 1
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.
static final intAUTO = 2
The height will grow automatically to accommodate all text inside an object.
 

    • Field Detail

      • AT_LEAST = 0

        public static final 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.
      • EXACTLY = 1

        public static final 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.
      • AUTO = 2

        public static final int AUTO
        The height will grow automatically to accommodate all text inside an object.