com.aspose.words

Class ListLevelAlignment

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

Utility class containing constants. Specifies alignment for the list number or bullet.

Used as a value for the ListLevel.Alignment property.

Example:

Shows how to apply custom list formatting to paragraphs when using DocumentBuilder.
Document doc = new Document();

// Create a list based on one of the Microsoft Word list templates
List list = doc.getLists().add(ListTemplate.NUMBER_DEFAULT);

// Completely customize one list level
ListLevel listLevel = list.getListLevels().get(0);
listLevel.getFont().setColor(Color.RED);
listLevel.getFont().setSize(24.0);
listLevel.setNumberStyle(NumberStyle.ORDINAL_TEXT);
listLevel.setStartAt(21);
listLevel.setNumberFormat("\u0000");

listLevel.setNumberPosition(-36);
listLevel.setTextPosition(144.0);
listLevel.setTabPosition(144.0);

// Customize another list level
listLevel = list.getListLevels().get(1);
listLevel.setAlignment(ListLevelAlignment.RIGHT);
listLevel.setNumberStyle(NumberStyle.BULLET);
listLevel.getFont().setName("Wingdings");
listLevel.getFont().setColor(Color.BLUE);
listLevel.getFont().setSize(24.0);
listLevel.setNumberFormat("\uf0af"); // A bullet that looks like a star
listLevel.setTrailingCharacter(ListTrailingCharacter.SPACE);
listLevel.setNumberPosition(144.0);

// Now add some text that uses the list that we created
// It does not matter when to customize the list - before or after adding the paragraphs
DocumentBuilder builder = new DocumentBuilder(doc);

builder.getListFormat().setList(list);
builder.writeln("The quick brown fox...");
builder.writeln("The quick brown fox...");

builder.getListFormat().listIndent();
builder.writeln("jumped over the lazy dog.");
builder.writeln("jumped over the lazy dog.");

builder.getListFormat().listOutdent();
builder.writeln("The quick brown fox...");

builder.getListFormat().removeNumbers();

builder.getDocument().save(getArtifactsDir() + "Lists.CreateCustomList.docx");

Field Summary
static final intLEFT = 0
The list label is aligned to the left of the number position.
static final intCENTER = 1
The list label is centered at the number position.
static final intRIGHT = 2
This list label is aligned to the right of the number position.
 

    • Field Detail

      • LEFT = 0

        public static final int LEFT
        The list label is aligned to the left of the number position.
      • CENTER = 1

        public static final int CENTER
        The list label is centered at the number position.
      • RIGHT = 2

        public static final int RIGHT
        This list label is aligned to the right of the number position.