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

Free Support Forum - aspose.com

doc.getRange().getText() does not return bullets

I have tried doc.getRange().getText() and tried getting text from document visitor class.
But in both the cases I do not get the bullets (numbers) info. So for example if in word
it shows up like:

  1. Item1
  2. Item2

The text that is get back from doc.getRange().getText() is only Item1 Item2.

Is there way around it?

Thanks

Hi,


Thanks for your inquiry. Sure, the 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(“C:\Temp\in.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())
{
System.out.println(“Paragraph #{0}” + listParaCount);

    <font color="GREEN"><i>// 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 <font color="BLUE">=</font> paragraph<font color="BLUE"><b>.</b></font>getListLabel<font color="BLUE"><b>(</b></font><font color="BLUE"><b>)</b></font><font color="BLUE"><b>;</b></font>
    <font color="GREEN"><i>// 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());

    <font color="GREEN"><i>// 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<font color="BLUE"><font color="BLUE">+</font><font color="BLUE">+</font></font><font color="BLUE"><b>;</b></font>
<font color="BLUE"><b>}</b></font>

}

I hope, this helps.

Best regards,