Free Support Forum - aspose.com

How to get the Bullet Numbers of Paragraph?

Hello,

I need some help here, I am trying to Read a word document using Aspose.Word. What I am trying to do is whenever I hit a number (in any format, i.e. numeric, roman or alphabetic) save the paragraph into my database.

I have attached a test document, which has bullet numbers for each paragraph. When I use this document and when it reaches the VisitParagraphStart function of my program, Paragraph.Range.Text is returning only the TEXT and IGNORING the bullet numbers(i.e. 1,2,3 or a,b,c…) . In order to work properly, I need to retrieve the text of each paragraph along with the actual bullet numbers. Please give me a code example how to achieve that. Thanks.

Here is my function:

Public Overrides Function VisitParagraphStart(ByVal paragraph As Aspose.Words.Paragraph) As Aspose.Words.VisitorAction

Try

Dim sText As String = paragraph.Range.Text.Trim()

‘HERE, I need to get the full string ALONG WITH the numbering, BUT all I am getting is text without the bullet numbers.

‘StartWithNumber is a simple function that checks if the first character is a number (i.e. 1,2,3... or a,b,c... or I,II,III...)

If sText.StartWithNumber Then Msgbox(sText)

Return VisitorAction.Continue

Catch ex As Exception

'In case of Error, Keep going to Next Node.

Return VisitorAction.SkipThisNode

End Try

End Function

Please give me a code example of how to retrieve the text of each paragraph ALONG WITH the actual Bullet Numbering. Thanks very much in advance.

Jerry.

Hi

Thanks for your inquiry. Unfortunately, you can’t get the bullet numbers using Aspose.Words. This numbers is rendered by MS Word, that’s why Aspose.Words can’t get these values for each paragraph in the document.

Best regards.

Is there any other way around?

Really, all I need is to get the number of each item on a list.

Hi

Unfortunately, there are no workarounds for this problem.

Best regards.

OK, Is there any way I can determine if the current paragraph is part of a List? And once I know that it is, then I need to get the parameters of the list (i.e. numbering format etc). Is this possible?

Hi

You can try to use the following code.

if (paragraph.IsListItem)

{

if (paragraph.ListFormat.List.Equals(list))

{

//paragraph is member of list

string format = paragraph.ListFormat.ListLevel.NumberFormat; //get number format

}

}

I hope that this will help you.

Best regards.

I tried the following code, but it gives me empty string or a box type character (usually this char is used for Tab or New Line). Please take a look:

Public Overrides Function VisitParagraphStart(ByVal paragraph As Aspose.Words.Paragraph) As Aspose.Words.VisitorAction

If paragraph.IsListItem Then MsgBox(paragraph.ListFormat.ListLevel.NumberFormat)

End Function

Hi

Thanks for your inquiry. I get "\0." and this is correct result. The NumberStyle property returns or sets the number style for this list level. See the following link for more information.
http://www.aspose.com/Products/Aspose.Words/Api/Aspose.Words.ListLevel.NumberStyle.html

Best regards.