Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Wed Mar 16, 2022 12:45 pm

Hi Team ,

Please let me know , how to get the total number of tabs or space occupied before the bullet points (including nested bullet points)

Thanks in advance

pr20080798
 
Posts: 146
Joined: Wed Jan 20, 2021 1:15 pm

Thu Mar 17, 2022 10:31 am

Hello,

Thank you for your inquiry.
The tab character is represented by the "\t" in word document, if you get the number of "\t" in paragraph text, you can get the total number of tabs in paragraph. However, after my investigation, the tabs will be automatically removed if you set bullet points (list) for paragraph, instead it will convert to the number position for list. You could use the follow code to get the number position of list. If there is any question, please provide your Word document for further investigation. You could attach it here or send to us via email (support@e-iceblue.com).
Code: Select all
   //load word document
            Document document = new Document();
            document.LoadFromFile(fileDir + "\\test.docx");
            //get the section
            Section section = document.Sections[0];
            //loop through paragraphs
            foreach (Paragraph paragraph in section.Body.Paragraphs)
            {
                //judge if the paragraph contains list
                if (paragraph.ListFormat.ListType != ListType.NoList)
                {
                    //get number position
                    float numberPosition = paragraph.ListFormat.CurrentListLevel.NumberPosition;
                }
            }

Sincerely,
Kylie
E-iceblue support team
User avatar

kylie.tian
 
Posts: 412
Joined: Mon Mar 07, 2022 2:30 am

Thu Mar 17, 2022 11:28 am

Thank you for your response.

I tried your code to fetch the position of bullet points but I am getting same position number -18.0 to all .

code I tried :
Document doc = new Document();
doc.loadFromFile("");
for(int i = 0;i<doc.getSections().getCount();i++) {
for(int j=0;j<doc.getSections().get(i).getParagraphs().getCount();j++) {
Paragraph paragraph = doc.getSections().get(i).getParagraphs().get(j);
if(paragraph.getListFormat().getListType() != ListType.No_List) {
float numberPosition = paragraph.getListFormat().getCurrentListLevel().getNumberPosition();
System.out.println("postion of "+paragraph.getText()+" "+numberPosition); }}

Thanks in advance

pr20080798
 
Posts: 146
Joined: Wed Jan 20, 2021 1:15 pm

Fri Mar 18, 2022 10:39 am

Hello,

Thanks for your reply.
Please use the following code instead to get the space before list. I have tested it would take effect.

Code: Select all
for(int i = 0;i<doc.getSections().getCount();i++) {
            for (int j = 0; j < doc.getSections().get(i).getParagraphs().getCount(); j++) {
                Paragraph paragraph = doc.getSections().get(i).getParagraphs().get(j);
                if (paragraph.getListFormat().getListType() != ListType.No_List) {
                    leftIndent= paragraph.getListFormat().getCurrentListLevel().getParagraphFormat().getLeftIndent();
                    System.out.println("postion of " + paragraph.getText() + " " + leftIndent);
                    }
                }
         }


Sincerely,
Kylie
E-iceblue support team
User avatar

kylie.tian
 
Posts: 412
Joined: Mon Mar 07, 2022 2:30 am

Thu Mar 24, 2022 3:19 am

Hi,

Hope you are doing well!
Has your problem been effectively solved now? Can you give us some feedback at your convenience?
Thanks in advance.

Sincerely,
Kylie
E-iceblue support team
User avatar

kylie.tian
 
Posts: 412
Joined: Mon Mar 07, 2022 2:30 am

Return to Spire.Doc