Free Support Forum - aspose.com

Replace Alphabets List to String One Per Line

Hello Aspose team,
I want to replace Alphabets List to Strings.

for example, this is my list (I am using … to show this is alphabets list)
…A. option 1
…B. option 2
…C. option 3

and I want them as strings, one per line

A. option 1
B. option 2
C. option 3

and I want to convert all of the list on my ODT doucment this way to strings, but I wanna keep the options with alphabets as A, B and C

Thanks in advance
Arbaz

@aadi1295,

Please try using the following code. Hope, this helps.

Document doc = new Document("D:\\temp\\in.docx");

doc.UpdateListLabels();
foreach(Paragraph para in doc.GetChildNodes(NodeType.Paragraph, true))
{
    if (para.IsListItem)
    {
        Run run = (Run) para.Runs[0].Clone(false);
        run.Text = para.ListLabel.LabelString + " ";
        para.Runs.Insert(0, run);

        para.ListFormat.List = null;
    }
}

doc.Save("D:\\temp\\18.9.docx");

Thanks Awais,
It worked like a charm