Apply one numbering list to a whole document

Hi,

How can I apply one numbering list to a whole document by code? documentBuilder.ListFormat.List.

Thanks

This message was posted using Email2Forum by babar.raza.

Hello

Thanks for your request. In this case you can try using the following code:

Document doc = new Document("C:\\Temp\\in.docx");
// Create list.
List list = doc.Lists.Add(ListTemplate.NumberDefault);
// Apply list formatting to all paragraphs.
foreach (Paragraph paragraph in doc.GetChildNodes(NodeType.Paragraph, true))
    paragraph.ListFormat.List = list;
doc.Save("C:\\Temp\\out.docx");

Please let me know in case of any issues. I will be glad to help you.

Best regards,