Free Support Forum -

Format Line Number of Word document using .NET

Hi, is it possible to have custom line numbers? I need to have instead of just numbers, I would like to have the numbers + a dot like
instead of
is that possible? I attached a sample document of what should be the expected output.test-pdf.pdf (7.4 KB)


Please note that Aspose.Words mimics the behavior of MS Word. The style ‘Line Number’ allows you to format the line numbers. You can modify this style using Aspose.Words and MS Word. However, there are some limitation for this style. Please read the following article about formatting line number.
Formatting Line Numbers (Microsoft Word)

If you still face problem, please manually create your expected Word document using Microsoft Word and attach it here for our reference. We will investigate how you want your final Word output be generated like. We will then provide you more information on this along with code.

Hi @tahir.manzoor this is the expected output that I am looking for (21.2 KB) Please let me know if there is a way to achieve this.

Thansk, regards.


You have added Shape (textbox) into header of document that contains paragraphs with double line spacing. The paragraph’s text is 1. 2. etc. With Aspose.Words, you can insert shape into header of document and insert paragraphs into it. We are writing code example for this case and will share it with you soon.


Following code example shows how to insert shape into header of document and insert paragraphs with text 1.,2., etc. Hope this helps you.

    Document doc = new Document();
    DocumentBuilder builder = new DocumentBuilder(doc);

    builder.ParagraphFormat.LineSpacing = 24;

    Shape rect = new Shape(doc, ShapeType.TextBox)
        Width = 50,
        Height = 650,
        Left = -78,
        Top = 0
    rect.RelativeHorizontalPosition = RelativeHorizontalPosition.Margin;
    rect.RelativeVerticalPosition = RelativeVerticalPosition.Margin;
    rect.StrokeWeight = 0;
    rect.Stroke.On = false;
    rect.BehindText = false;

    for (int i = 1; i <= 23; i++)
        Paragraph p = new Paragraph(doc);
        p.Runs.Add(new Run(doc, i + "."));
        p.ParagraphFormat.LineSpacing = 24;
        p.ParagraphFormat.Alignment = ParagraphAlignment.Right;

    doc.FirstSection.Body.FirstParagraph.ParagraphFormat.LineSpacing = 24;
    doc.Save(MyDir + @"21.2.docx");