com.aspose.words

  • java.lang.Object
    • com.aspose.words.Style
  • All Implemented Interfaces:
    java.lang.Cloneable
    Direct Known Subclasses:
    TableStyle
    public class Style 
    extends java.lang.Object

Represents a single built-in or user-defined style.

Example:

Shows how to create and use a paragraph style with list formatting.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Create a paragraph style and specify some formatting for it
Style style = doc.getStyles().add(StyleType.PARAGRAPH, "MyStyle1");
style.getFont().setSize(24.0);
style.getFont().setName("Verdana");
style.getParagraphFormat().setSpaceAfter(12.0);

// Create a list and make sure the paragraphs that use this style will use this list
style.getListFormat().setList(doc.getLists().add(ListTemplate.BULLET_DEFAULT));
style.getListFormat().setListLevelNumber(0);

// Apply the paragraph style to the current paragraph in the document and add some text
builder.getParagraphFormat().setStyle(style);
builder.writeln("Hello World: MyStyle1, bulleted list.");

// Change to a paragraph style that has no list formatting
builder.getParagraphFormat().setStyle(doc.getStyles().get("Normal"));
builder.writeln("Hello World: Normal.");

builder.getDocument().save(getArtifactsDir() + "Styles.ParagraphStyleBulletedList.docx");

Example:

Shows how to create and apply a style.
Document doc = new Document();

// Add a custom style and change its appearance
Style style = doc.getStyles().add(StyleType.PARAGRAPH, "MyStyle");
style.getFont().setName("Times New Roman");
style.getFont().setSize(16.0);
style.getFont().setColor(Color.magenta);

// Write a paragraph in that style
DocumentBuilder builder = new DocumentBuilder(doc);
builder.getParagraphFormat().setStyle(doc.getStyles().get("MyStyle"));
builder.writeln("Hello world!");

Style firstParagraphStyle = doc.getFirstSection().getBody().getFirstParagraph().getParagraphFormat().getStyle();

Assert.assertEquals(style, firstParagraphStyle);

// Styles can also be removed from the collection like this
doc.getStyles().get("MyStyle").remove();

firstParagraphStyle = doc.getFirstSection().getBody().getFirstParagraph().getParagraphFormat().getStyle();

// Removing the style reverts the styling of the text that was in that style
Assert.assertEquals("Times New Roman", firstParagraphStyle.getFont().getName());
Assert.assertEquals(12.0d, firstParagraphStyle.getFont().getSize());
Assert.assertEquals(0, firstParagraphStyle.getFont().getColor().getRGB());

Property Getters/Setters Summary
java.lang.String[]getAliases()
Gets all aliases of this style. If style has no aliases then empty array of string is returned.
java.lang.StringgetBaseStyleName()
void
setBaseStyleName(java.lang.Stringvalue)
           Gets/sets the name of the style this style is based on.
booleangetBuiltIn()
True if this style is one of the built-in styles in MS Word.
DocumentBasegetDocument()
Gets the owner document.
FontgetFont()
Gets the character formatting of the style.
booleanisHeading()
True when the style is one of the built-in Heading styles.
booleanisQuickStyle()
void
isQuickStyle(booleanvalue)
           Specifies whether this style is shown in the Quick Style gallery inside MS Word UI.
java.lang.StringgetLinkedStyleName()
Gets the name of the Style linked to this one. Returns Empty string if no styles are linked.
ListgetList()
Gets the list that defines formatting of this list style.
ListFormatgetListFormat()
Provides access to the list formatting properties of a paragraph style.
java.lang.StringgetName()
void
setName(java.lang.Stringvalue)
           Gets or sets the name of the style.
java.lang.StringgetNextParagraphStyleName()
void
setNextParagraphStyleName(java.lang.Stringvalue)
           Gets/sets the name of the style to be applied automatically to a new paragraph inserted after a paragraph formatted with the specified style.
ParagraphFormatgetParagraphFormat()
Gets the paragraph formatting of the style.
intgetStyleIdentifier()
Gets the locale independent style identifier for a built-in style. The value of the property is StyleIdentifier integer constant.
StyleCollectiongetStyles()
Gets the collection of styles this style belongs to.
intgetType()
Gets the style type (paragraph or character). The value of the property is StyleType integer constant.
 
Method Summary
booleanequals(Style style)
Compares with the specified style. Styles Istds are compared for built-in styles only. Styles defaults are not included in comparison. Base style, linked style and next paragraph style are recursively compared.
voidremove()
Removes the specified style from the document.
 

    • Property Getters/Setters Detail

      • getAliases

        public java.lang.String[] getAliases()
        
        Gets all aliases of this style. If style has no aliases then empty array of string is returned.

        Example:

        Shows how to use style aliases.
        Document doc = new Document(getMyDir() + "Style with alias.docx");
        
        // If a style's name has multiple values separated by commas, each one is considered to be a separate alias
        Style style = doc.getStyles().get("MyStyle");
        Assert.assertEquals(new String[]{"MyStyle Alias 1", "MyStyle Alias 2"}, style.getAliases());
        Assert.assertEquals("Title", style.getBaseStyleName());
        Assert.assertEquals("MyStyle Char", style.getLinkedStyleName());
        
        // A style can be referenced by alias as well as name
        Assert.assertEquals(style, doc.getStyles().get("MyStyle Alias 1"));
      • getBaseStyleName/setBaseStyleName

        public java.lang.String getBaseStyleName() / public void setBaseStyleName(java.lang.String value)
        
        Gets/sets the name of the style this style is based on. This will be an empty string if the style is not based on any other style and it can be set to an empty string.

        Example:

        Shows how to use style aliases.
        Document doc = new Document(getMyDir() + "Style with alias.docx");
        
        // If a style's name has multiple values separated by commas, each one is considered to be a separate alias
        Style style = doc.getStyles().get("MyStyle");
        Assert.assertEquals(new String[]{"MyStyle Alias 1", "MyStyle Alias 2"}, style.getAliases());
        Assert.assertEquals("Title", style.getBaseStyleName());
        Assert.assertEquals("MyStyle Char", style.getLinkedStyleName());
        
        // A style can be referenced by alias as well as name
        Assert.assertEquals(style, doc.getStyles().get("MyStyle Alias 1"));
      • getBuiltIn

        public boolean getBuiltIn()
        
        True if this style is one of the built-in styles in MS Word.

        Example:

        Shows how to differentiate custom styles from built-in styles.
        Document doc = new Document();
        
        // When we create a document using Microsoft Word, or programmatically using Aspose.Words,
        // the document will come with a collection of styles to apply to its text to modify its appearance.
        // We can access these built-in styles via the document's "Styles" collection.
        // These styles will all have the "BuiltIn" flag set to "true".
        Style style = doc.getStyles().get("Emphasis");
        
        Assert.assertTrue(style.getBuiltIn());
        
        // Create a custom style, and add it to the collection.
        // Custom styles such as this will have the "BuiltIn" flag set to "false". 
        style = doc.getStyles().add(StyleType.CHARACTER, "MyStyle");
        style.getFont().setColor(Color.RED);
        style.getFont().setName("Courier New");
        
        Assert.assertFalse(style.getBuiltIn());
      • getDocument

        public DocumentBase getDocument()
        
        Gets the owner document.

        Example:

        Shows how to access a document's style collection.
        Document doc = new Document();
        
        // A blank document comes with 4 styles by default
        Assert.assertEquals(4, doc.getStyles().getCount());
        
        Iterator<Style> stylesEnum = doc.getStyles().iterator();
        while (stylesEnum.hasNext()) {
            Style curStyle = stylesEnum.next();
            System.out.println(MessageFormat.format("Style name:\t\"{0}\", of type \"{1}\"", curStyle.getName(), curStyle.getType()));
            System.out.println(MessageFormat.format("\tSubsequent style:\t{0}", curStyle.getNextParagraphStyleName()));
            System.out.println(MessageFormat.format("\tIs heading:\t\t\t{0}", curStyle.isHeading()));
            System.out.println(MessageFormat.format("\tIs QuickStyle:\t\t{0}", curStyle.isQuickStyle()));
        
            Assert.assertEquals(curStyle.getDocument(), doc);
        }
      • getFont

        public Font getFont()
        
        Gets the character formatting of the style.

        For list styles this property returns null.

        Example:

        Shows how to create and use a paragraph style with list formatting.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        // Create a paragraph style and specify some formatting for it
        Style style = doc.getStyles().add(StyleType.PARAGRAPH, "MyStyle1");
        style.getFont().setSize(24.0);
        style.getFont().setName("Verdana");
        style.getParagraphFormat().setSpaceAfter(12.0);
        
        // Create a list and make sure the paragraphs that use this style will use this list
        style.getListFormat().setList(doc.getLists().add(ListTemplate.BULLET_DEFAULT));
        style.getListFormat().setListLevelNumber(0);
        
        // Apply the paragraph style to the current paragraph in the document and add some text
        builder.getParagraphFormat().setStyle(style);
        builder.writeln("Hello World: MyStyle1, bulleted list.");
        
        // Change to a paragraph style that has no list formatting
        builder.getParagraphFormat().setStyle(doc.getStyles().get("Normal"));
        builder.writeln("Hello World: Normal.");
        
        builder.getDocument().save(getArtifactsDir() + "Styles.ParagraphStyleBulletedList.docx");

        Example:

        Shows how to create and apply a style.
        Document doc = new Document();
        
        // Add a custom style and change its appearance
        Style style = doc.getStyles().add(StyleType.PARAGRAPH, "MyStyle");
        style.getFont().setName("Times New Roman");
        style.getFont().setSize(16.0);
        style.getFont().setColor(Color.magenta);
        
        // Write a paragraph in that style
        DocumentBuilder builder = new DocumentBuilder(doc);
        builder.getParagraphFormat().setStyle(doc.getStyles().get("MyStyle"));
        builder.writeln("Hello world!");
        
        Style firstParagraphStyle = doc.getFirstSection().getBody().getFirstParagraph().getParagraphFormat().getStyle();
        
        Assert.assertEquals(style, firstParagraphStyle);
        
        // Styles can also be removed from the collection like this
        doc.getStyles().get("MyStyle").remove();
        
        firstParagraphStyle = doc.getFirstSection().getBody().getFirstParagraph().getParagraphFormat().getStyle();
        
        // Removing the style reverts the styling of the text that was in that style
        Assert.assertEquals("Times New Roman", firstParagraphStyle.getFont().getName());
        Assert.assertEquals(12.0d, firstParagraphStyle.getFont().getSize());
        Assert.assertEquals(0, firstParagraphStyle.getFont().getColor().getRGB());
      • isHeading

        public boolean isHeading()
        
        True when the style is one of the built-in Heading styles.

        Example:

        Shows how to access a document's style collection.
        Document doc = new Document();
        
        // A blank document comes with 4 styles by default
        Assert.assertEquals(4, doc.getStyles().getCount());
        
        Iterator<Style> stylesEnum = doc.getStyles().iterator();
        while (stylesEnum.hasNext()) {
            Style curStyle = stylesEnum.next();
            System.out.println(MessageFormat.format("Style name:\t\"{0}\", of type \"{1}\"", curStyle.getName(), curStyle.getType()));
            System.out.println(MessageFormat.format("\tSubsequent style:\t{0}", curStyle.getNextParagraphStyleName()));
            System.out.println(MessageFormat.format("\tIs heading:\t\t\t{0}", curStyle.isHeading()));
            System.out.println(MessageFormat.format("\tIs QuickStyle:\t\t{0}", curStyle.isQuickStyle()));
        
            Assert.assertEquals(curStyle.getDocument(), doc);
        }
      • isQuickStyle/isQuickStyle

        public boolean isQuickStyle() / public void isQuickStyle(boolean value)
        
        Specifies whether this style is shown in the Quick Style gallery inside MS Word UI.

        Example:

        Shows how to access a document's style collection.
        Document doc = new Document();
        
        // A blank document comes with 4 styles by default
        Assert.assertEquals(4, doc.getStyles().getCount());
        
        Iterator<Style> stylesEnum = doc.getStyles().iterator();
        while (stylesEnum.hasNext()) {
            Style curStyle = stylesEnum.next();
            System.out.println(MessageFormat.format("Style name:\t\"{0}\", of type \"{1}\"", curStyle.getName(), curStyle.getType()));
            System.out.println(MessageFormat.format("\tSubsequent style:\t{0}", curStyle.getNextParagraphStyleName()));
            System.out.println(MessageFormat.format("\tIs heading:\t\t\t{0}", curStyle.isHeading()));
            System.out.println(MessageFormat.format("\tIs QuickStyle:\t\t{0}", curStyle.isQuickStyle()));
        
            Assert.assertEquals(curStyle.getDocument(), doc);
        }
      • getLinkedStyleName

        public java.lang.String getLinkedStyleName()
        
        Gets the name of the Style linked to this one. Returns Empty string if no styles are linked.

        Example:

        Shows how to use style aliases.
        Document doc = new Document(getMyDir() + "Style with alias.docx");
        
        // If a style's name has multiple values separated by commas, each one is considered to be a separate alias
        Style style = doc.getStyles().get("MyStyle");
        Assert.assertEquals(new String[]{"MyStyle Alias 1", "MyStyle Alias 2"}, style.getAliases());
        Assert.assertEquals("Title", style.getBaseStyleName());
        Assert.assertEquals("MyStyle Char", style.getLinkedStyleName());
        
        // A style can be referenced by alias as well as name
        Assert.assertEquals(style, doc.getStyles().get("MyStyle Alias 1"));
      • getList

        public List getList()
        
        Gets the list that defines formatting of this list style.

        This property is only valid for list styles. For other style types this property returns null.

        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
        Assert.assertTrue(list1.isListStyleDefinition());
        Assert.assertFalse(list1.isListStyleReference());
        Assert.assertTrue(list1.isMultiLevel());
        Assert.assertEquals(listStyle, list1.getStyle());
        
        // Modify formatting of the list style to our liking
        for (ListLevel level : list1.getListLevels()) {
            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
        Assert.assertFalse(list2.isListStyleDefinition());
        Assert.assertTrue(list2.isListStyleReference());
        Assert.assertEquals(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.docx");
      • getListFormat

        public ListFormat getListFormat()
        
        Provides access to the list formatting properties of a paragraph style.

        This property is only valid for paragraph styles. For other style types this property returns null.

        Example:

        Shows how to create and use a paragraph style with list formatting.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        // Create a paragraph style and specify some formatting for it
        Style style = doc.getStyles().add(StyleType.PARAGRAPH, "MyStyle1");
        style.getFont().setSize(24.0);
        style.getFont().setName("Verdana");
        style.getParagraphFormat().setSpaceAfter(12.0);
        
        // Create a list and make sure the paragraphs that use this style will use this list
        style.getListFormat().setList(doc.getLists().add(ListTemplate.BULLET_DEFAULT));
        style.getListFormat().setListLevelNumber(0);
        
        // Apply the paragraph style to the current paragraph in the document and add some text
        builder.getParagraphFormat().setStyle(style);
        builder.writeln("Hello World: MyStyle1, bulleted list.");
        
        // Change to a paragraph style that has no list formatting
        builder.getParagraphFormat().setStyle(doc.getStyles().get("Normal"));
        builder.writeln("Hello World: Normal.");
        
        builder.getDocument().save(getArtifactsDir() + "Styles.ParagraphStyleBulletedList.docx");
      • getName/setName

        public java.lang.String getName() / public void setName(java.lang.String value)
        
        Gets or sets the name of the style.

        Can not be empty string.

        If there already is a style with such name in the collection, then this style will override it. All affected nodes will reference new style.

        Example:

        Shows how to copy a style within the same document.
        Document doc = new Document(getMyDir() + "Document.docx");
        
        // The AddCopy method creates a copy of the specified style and automatically generates a new name for the style, such as "Heading 1_0"
        Style newStyle = doc.getStyles().addCopy(doc.getStyles().get("Heading 1"));
        // You can change the new style name if required as the Style.Name property is read-write
        newStyle.setName("My Heading 1");

        Example:

        Shows how to access a document's style collection.
        Document doc = new Document();
        
        // A blank document comes with 4 styles by default
        Assert.assertEquals(4, doc.getStyles().getCount());
        
        Iterator<Style> stylesEnum = doc.getStyles().iterator();
        while (stylesEnum.hasNext()) {
            Style curStyle = stylesEnum.next();
            System.out.println(MessageFormat.format("Style name:\t\"{0}\", of type \"{1}\"", curStyle.getName(), curStyle.getType()));
            System.out.println(MessageFormat.format("\tSubsequent style:\t{0}", curStyle.getNextParagraphStyleName()));
            System.out.println(MessageFormat.format("\tIs heading:\t\t\t{0}", curStyle.isHeading()));
            System.out.println(MessageFormat.format("\tIs QuickStyle:\t\t{0}", curStyle.isQuickStyle()));
        
            Assert.assertEquals(curStyle.getDocument(), doc);
        }
      • getNextParagraphStyleName/setNextParagraphStyleName

        public java.lang.String getNextParagraphStyleName() / public void setNextParagraphStyleName(java.lang.String value)
        
        Gets/sets the name of the style to be applied automatically to a new paragraph inserted after a paragraph formatted with the specified style. This property is not used by Aspose.Words. The next paragraph style will only be applied automatically when you edit the document in MS Word.

        Example:

        Shows how to access a document's style collection.
        Document doc = new Document();
        
        // A blank document comes with 4 styles by default
        Assert.assertEquals(4, doc.getStyles().getCount());
        
        Iterator<Style> stylesEnum = doc.getStyles().iterator();
        while (stylesEnum.hasNext()) {
            Style curStyle = stylesEnum.next();
            System.out.println(MessageFormat.format("Style name:\t\"{0}\", of type \"{1}\"", curStyle.getName(), curStyle.getType()));
            System.out.println(MessageFormat.format("\tSubsequent style:\t{0}", curStyle.getNextParagraphStyleName()));
            System.out.println(MessageFormat.format("\tIs heading:\t\t\t{0}", curStyle.isHeading()));
            System.out.println(MessageFormat.format("\tIs QuickStyle:\t\t{0}", curStyle.isQuickStyle()));
        
            Assert.assertEquals(curStyle.getDocument(), doc);
        }
      • getParagraphFormat

        public ParagraphFormat getParagraphFormat()
        
        Gets the paragraph formatting of the style.

        For character and list styles this property returns null.

        Example:

        Shows how to create and use a paragraph style with list formatting.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        // Create a paragraph style and specify some formatting for it
        Style style = doc.getStyles().add(StyleType.PARAGRAPH, "MyStyle1");
        style.getFont().setSize(24.0);
        style.getFont().setName("Verdana");
        style.getParagraphFormat().setSpaceAfter(12.0);
        
        // Create a list and make sure the paragraphs that use this style will use this list
        style.getListFormat().setList(doc.getLists().add(ListTemplate.BULLET_DEFAULT));
        style.getListFormat().setListLevelNumber(0);
        
        // Apply the paragraph style to the current paragraph in the document and add some text
        builder.getParagraphFormat().setStyle(style);
        builder.writeln("Hello World: MyStyle1, bulleted list.");
        
        // Change to a paragraph style that has no list formatting
        builder.getParagraphFormat().setStyle(doc.getStyles().get("Normal"));
        builder.writeln("Hello World: Normal.");
        
        builder.getDocument().save(getArtifactsDir() + "Styles.ParagraphStyleBulletedList.docx");
      • getStyleIdentifier

        public int getStyleIdentifier()
        
        Gets the locale independent style identifier for a built-in style. The value of the property is StyleIdentifier integer constant.

        For user defined (custom) styles, this property returns StyleIdentifier.USER.

        Example:

        Shows how to modify the position of the right tab stop in TOC related paragraphs.
        Document doc = new Document(getMyDir() + "Table of contents.docx");
        
        // Iterate through all paragraphs formatted using the TOC result based styles; this is any style between TOC and TOC9
        for (Paragraph para : (Iterable<Paragraph>) doc.getChildNodes(NodeType.PARAGRAPH, true)) {
            if (para.getParagraphFormat().getStyle().getStyleIdentifier() >= StyleIdentifier.TOC_1
                    && para.getParagraphFormat().getStyle().getStyleIdentifier() <= StyleIdentifier.TOC_9) {
                // Get the first tab used in this paragraph, this should be the tab used to align the page numbers
                TabStop tab = para.getParagraphFormat().getTabStops().get(0);
                // Remove the old tab from the collection
                para.getParagraphFormat().getTabStops().removeByPosition(tab.getPosition());
                // Insert a new tab using the same properties but at a modified position
                // We could also change the separators used (dots) by passing a different Leader type
                para.getParagraphFormat().getTabStops().add(tab.getPosition() - 50, tab.getAlignment(), tab.getLeader());
            }
        }
        
        doc.save(getArtifactsDir() + "Styles.ChangeTocsTabStops.docx");
        See Also:
        Name
      • getStyles

        public StyleCollection getStyles()
        
        Gets the collection of styles this style belongs to.

        Example:

        Shows how to access a document's style collection.
        Document doc = new Document();
        
        // A blank document comes with 4 styles by default
        Assert.assertEquals(4, doc.getStyles().getCount());
        
        Iterator<Style> stylesEnum = doc.getStyles().iterator();
        while (stylesEnum.hasNext()) {
            Style curStyle = stylesEnum.next();
            System.out.println(MessageFormat.format("Style name:\t\"{0}\", of type \"{1}\"", curStyle.getName(), curStyle.getType()));
            System.out.println(MessageFormat.format("\tSubsequent style:\t{0}", curStyle.getNextParagraphStyleName()));
            System.out.println(MessageFormat.format("\tIs heading:\t\t\t{0}", curStyle.isHeading()));
            System.out.println(MessageFormat.format("\tIs QuickStyle:\t\t{0}", curStyle.isQuickStyle()));
        
            Assert.assertEquals(curStyle.getDocument(), doc);
        }
      • getType

        public int getType()
        
        Gets the style type (paragraph or character). The value of the property is StyleType integer constant.

        Example:

        Shows how to access a document's style collection.
        Document doc = new Document();
        
        // A blank document comes with 4 styles by default
        Assert.assertEquals(4, doc.getStyles().getCount());
        
        Iterator<Style> stylesEnum = doc.getStyles().iterator();
        while (stylesEnum.hasNext()) {
            Style curStyle = stylesEnum.next();
            System.out.println(MessageFormat.format("Style name:\t\"{0}\", of type \"{1}\"", curStyle.getName(), curStyle.getType()));
            System.out.println(MessageFormat.format("\tSubsequent style:\t{0}", curStyle.getNextParagraphStyleName()));
            System.out.println(MessageFormat.format("\tIs heading:\t\t\t{0}", curStyle.isHeading()));
            System.out.println(MessageFormat.format("\tIs QuickStyle:\t\t{0}", curStyle.isQuickStyle()));
        
            Assert.assertEquals(curStyle.getDocument(), doc);
        }
    • Method Detail

      • equals

        public boolean equals(Style style)
        Compares with the specified style. Styles Istds are compared for built-in styles only. Styles defaults are not included in comparison. Base style, linked style and next paragraph style are recursively compared.

        Example:

        Shows how to use style aliases.
        Document doc = new Document(getMyDir() + "Style with alias.docx");
        
        // If a style's name has multiple values separated by commas, each one is considered to be a separate alias
        Style style = doc.getStyles().get("MyStyle");
        Assert.assertEquals(new String[]{"MyStyle Alias 1", "MyStyle Alias 2"}, style.getAliases());
        Assert.assertEquals("Title", style.getBaseStyleName());
        Assert.assertEquals("MyStyle Char", style.getLinkedStyleName());
        
        // A style can be referenced by alias as well as name
        Assert.assertEquals(style, doc.getStyles().get("MyStyle Alias 1"));
      • remove

        public void remove()
        Removes the specified style from the document. Style removal has following effects on the document model:
        • All references to the style are removed from corresponding paragraphs, runs and tables.
        • If base style is removed its formatting is moved to child styles.
        • If style to be deleted has a linked style, then both of these are deleted.

        Example:

        Shows how to create and apply a style.
        Document doc = new Document();
        
        // Add a custom style and change its appearance
        Style style = doc.getStyles().add(StyleType.PARAGRAPH, "MyStyle");
        style.getFont().setName("Times New Roman");
        style.getFont().setSize(16.0);
        style.getFont().setColor(Color.magenta);
        
        // Write a paragraph in that style
        DocumentBuilder builder = new DocumentBuilder(doc);
        builder.getParagraphFormat().setStyle(doc.getStyles().get("MyStyle"));
        builder.writeln("Hello world!");
        
        Style firstParagraphStyle = doc.getFirstSection().getBody().getFirstParagraph().getParagraphFormat().getStyle();
        
        Assert.assertEquals(style, firstParagraphStyle);
        
        // Styles can also be removed from the collection like this
        doc.getStyles().get("MyStyle").remove();
        
        firstParagraphStyle = doc.getFirstSection().getBody().getFirstParagraph().getParagraphFormat().getStyle();
        
        // Removing the style reverts the styling of the text that was in that style
        Assert.assertEquals("Times New Roman", firstParagraphStyle.getFont().getName());
        Assert.assertEquals(12.0d, firstParagraphStyle.getFont().getSize());
        Assert.assertEquals(0, firstParagraphStyle.getFont().getColor().getRGB());