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

Free Support Forum - aspose.com

How can I change the bulleting/indentation/numbering of an existing document

Hi,

I want to change the bulleting/indentation/numbering of an existing document. Can you please provide me the code for that.

So my use-case is that I have some clauses (like paragraphs) and I want to generate a document from them. I want to indent or number them based on user input. My clauses can already be indented or numbered. So can i change the exiting numbering or indentation.

Thanks,
Saurabh

@saurabh.arora,

Thanks for your inquiry. In your case, we suggest you please create a new list according to your requirement and set it to the required paragraphs. Please check the following code example. Hope this helps you. We have attached the input and output documents with this post for your kind reference. Docs.zip (19.7 KB)

Document doc = new Document(MyDir + "in.docx");

List newList = doc.Lists.Add(ListTemplate.NumberDefault);

// Completely customize one list level.
ListLevel level1 = newList.ListLevels[0];
level1.NumberStyle = NumberStyle.OrdinalText;
level1.NumberFormat = "\x0000";

//Customize yet another list level.
ListLevel level2 = newList.ListLevels[1];
level2.Alignment = ListLevelAlignment.Right;
level2.NumberStyle = NumberStyle.Bullet;
level2.Font.Name = "Wingdings";
level2.Font.Color = Color.Blue;
level2.Font.Size = 24;
level2.NumberFormat = "\xf0af";    // A bullet that looks like some sort of a star.
level2.TrailingCharacter = ListTrailingCharacter.Space;
level2.NumberPosition = 144;


foreach (Paragraph paragraph in doc.GetChildNodes(NodeType.Paragraph, true))
{
    if (paragraph.ListFormat.IsListItem)
    {
        paragraph.ListFormat.List = newList;
    }
}

doc.Save(MyDir + "17.8.docx");