We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Read List Item (bullet or numbered) from paragraph using Java

is there a demo code to show , how to read the list items (bullet items) from ms word document using Aspose Java api ?


Following code example shows how to extract the label of each paragraph in a list as a value or a String.

Document doc = new Document(getMyDir() + "Rendering.docx");
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);


Thanks Tahir. It helps a lot. Though faced one issue, in getting the unordered list. The above code works well for the ordered list like a, b, c. i am not able to get the actual unordered list symbol used. Can you please help me on this ?


Could you please attach your input Word document here for testing? We will investigate the issue on our side and provide you more information.