com.aspose.words

Class ListLabel

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

Defines properties specific to a list label.

Example:

Shows how to extract the label of each paragraph in a list as a value or a String.
Document doc = new Document(getMyDir() + "Lists.PrintOutAllLists.doc");
doc.updateListLabels();
int listParaCount = 1;

for (Paragraph paragraph : (Iterable<Paragraph>) doc.getChildNodes(NodeType.PARAGRAPH, true))
{
    // Find if we have the paragraph list. In our document our list uses plain arabic numbers,
    // which start at three and ends at six.
    if (paragraph.getListFormat().isListItem())
    {
        System.out.println(MessageFormat.format("Paragraph #{0}", listParaCount));

        // This is the text we get when actually getting when we output this node to text format.
        // The list labels are not included in this text output. Trim any paragraph formatting characters.
        String paragraphText = paragraph.toString(SaveFormat.TEXT).trim();
        System.out.println("Exported Text: " + paragraphText);

        ListLabel label = paragraph.getListLabel();
        // This gets the position of the paragraph in current level of the list. If we have a list with multiple level then this
        // will tell us what position it is on that particular level.
        System.out.println("Numerical Id: " + label.getLabelValue());

        // Combine them together to include the list label with the text in the output.
        System.out.println("List label combined with text: " + label.getLabelString() + " " + paragraphText);

        listParaCount++;
    }
}

Property Getters/Setters Summary
FontgetFont()
Gets the list label font.
java.lang.StringgetLabelString()
Gets a string representation of list label.
intgetLabelValue()
Gets a numeric value for this label.
 

    • Property Getters/Setters Detail

      • getFont

        public Font getFont()
        
        Gets the list label font.
      • getLabelString

        public java.lang.String getLabelString()
        
        Gets a string representation of list label.

        Example:

        Shows how to extract the label of each paragraph in a list as a value or a String.
        Document doc = new Document(getMyDir() + "Lists.PrintOutAllLists.doc");
        doc.updateListLabels();
        int listParaCount = 1;
        
        for (Paragraph paragraph : (Iterable<Paragraph>) doc.getChildNodes(NodeType.PARAGRAPH, true))
        {
            // Find if we have the paragraph list. In our document our list uses plain arabic numbers,
            // which start at three and ends at six.
            if (paragraph.getListFormat().isListItem())
            {
                System.out.println(MessageFormat.format("Paragraph #{0}", listParaCount));
        
                // This is the text we get when actually getting when we output this node to text format.
                // The list labels are not included in this text output. Trim any paragraph formatting characters.
                String paragraphText = paragraph.toString(SaveFormat.TEXT).trim();
                System.out.println("Exported Text: " + paragraphText);
        
                ListLabel label = paragraph.getListLabel();
                // This gets the position of the paragraph in current level of the list. If we have a list with multiple level then this
                // will tell us what position it is on that particular level.
                System.out.println("Numerical Id: " + label.getLabelValue());
        
                // Combine them together to include the list label with the text in the output.
                System.out.println("List label combined with text: " + label.getLabelString() + " " + paragraphText);
        
                listParaCount++;
            }
        }
      • getLabelValue

        public int getLabelValue()
        
        Gets a numeric value for this label. Use the Document.updateListLabels() method to update the value of this property.

        Example:

        Shows how to extract the label of each paragraph in a list as a value or a String.
        Document doc = new Document(getMyDir() + "Lists.PrintOutAllLists.doc");
        doc.updateListLabels();
        int listParaCount = 1;
        
        for (Paragraph paragraph : (Iterable<Paragraph>) doc.getChildNodes(NodeType.PARAGRAPH, true))
        {
            // Find if we have the paragraph list. In our document our list uses plain arabic numbers,
            // which start at three and ends at six.
            if (paragraph.getListFormat().isListItem())
            {
                System.out.println(MessageFormat.format("Paragraph #{0}", listParaCount));
        
                // This is the text we get when actually getting when we output this node to text format.
                // The list labels are not included in this text output. Trim any paragraph formatting characters.
                String paragraphText = paragraph.toString(SaveFormat.TEXT).trim();
                System.out.println("Exported Text: " + paragraphText);
        
                ListLabel label = paragraph.getListLabel();
                // This gets the position of the paragraph in current level of the list. If we have a list with multiple level then this
                // will tell us what position it is on that particular level.
                System.out.println("Numerical Id: " + label.getLabelValue());
        
                // Combine them together to include the list label with the text in the output.
                System.out.println("List label combined with text: " + label.getLabelString() + " " + paragraphText);
        
                listParaCount++;
            }
        }