com.aspose.words

Class StyleType

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

Utility class containing constants. Represents type of the style.

Example:

Shows how to create a list style and use it in a document.
Document doc = new Document();

// Create a new list style
// List formatting associated with this list style is default numbered
Style listStyle = doc.getStyles().add(StyleType.LIST, "MyListStyle");

// This list defines the formatting of the list style
// Note this list can not be used directly to apply formatting to paragraphs (see below)
List list1 = listStyle.getList();

// Check some basic rules about the list that defines a list style
System.out.println("IsListStyleDefinition: " + list1.isListStyleDefinition());
System.out.println("IsListStyleReference: " + list1.isListStyleReference());
System.out.println("IsMultiLevel: " + list1.isMultiLevel());
System.out.println("List style has been set: " + (listStyle == list1.getStyle()));

// Modify formatting of the list style to our liking
for (int i = 0; i < list1.getListLevels().getCount(); i++) {
    ListLevel level = list1.getListLevels().get(i);
    level.getFont().setName("Verdana");
    level.getFont().setColor(Color.BLUE);
    level.getFont().setBold(true);
}

// Add some text to our document and use the list style
DocumentBuilder builder = new DocumentBuilder(doc);

builder.writeln("Using list style first time:");

// This creates a list based on the list style
List list2 = doc.getLists().add(listStyle);

// Check some basic rules about the list that references a list style
System.out.println("IsListStyleDefinition: " + list2.isListStyleDefinition());
System.out.println("IsListStyleReference: " + list2.isListStyleReference());
System.out.println("List Style has been set: " + (listStyle == list2.getStyle()));

// Apply the list that references the list style
builder.getListFormat().setList(list2);
builder.writeln("Item 1");
builder.writeln("Item 2");
builder.getListFormat().removeNumbers();

builder.writeln("Using list style second time:");

// Create and apply another list based on the list style
List list3 = doc.getLists().add(listStyle);
builder.getListFormat().setList(list3);
builder.writeln("Item 1");
builder.writeln("Item 2");
builder.getListFormat().removeNumbers();

builder.getDocument().save(getArtifactsDir() + "Lists.CreateAndUseListStyle.doc");

Field Summary
static final intPARAGRAPH = 1
The style is a paragraph style.
static final intCHARACTER = 2
The style is a character style.
static final intTABLE = 3
The style is a table style.
static final intLIST = 4
The style is a list style.
 

    • Field Detail

      • PARAGRAPH = 1

        public static final int PARAGRAPH
        The style is a paragraph style.
      • CHARACTER = 2

        public static final int CHARACTER
        The style is a character style.
      • TABLE = 3

        public static final int TABLE
        The style is a table style.
      • LIST = 4

        public static final int LIST
        The style is a list style.