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

Free Support Forum - aspose.com

How to get to the numberFormat of list level?

Input :

一、 安全管理防范规定
二、 规定了公共秩序维护管理的

三、 公共秩序维护管理规定

Java Code:
Paragraph.getListFormat().getListLevel().getNumberFormat();

Output :

Question:

  1. why The getNumberFormat return with empty string?
  2. How I can get the separator (、) of bullet ?

@Rammoslee

Could you please attach your input Word document here for our reference? We will then provide you more information about your query along with code example.

Hi @tahir.manzoor,
you can download the attach file with below url: https://drive.google.com/file/d/1yG9rxSUG2fZpYIy4Nlq0D6nFSx1qHL-J/view?usp=sharing

Thank

@Rammoslee

Please use the following code example to get the desired output. Hope this helps you.

Document doc = new Document(MyDir  + "ZH-Bullets_test3.docx");
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()) {
        
        // 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++;
    }
}