PageSetupLineNumberCountBy Property

Returns or sets the numeric increment for line numbers.

Namespace:  Aspose.Words
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.10.0


public int LineNumberCountBy { get; set; }

Property Value

Type: Int32


Shows how to enable Microsoft Word line numbering for a section.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Line numbering for each section can be configured via PageSetup
PageSetup pageSetup = builder.PageSetup;
pageSetup.LineStartingNumber = 1;
pageSetup.LineNumberCountBy = 3;
pageSetup.LineNumberRestartMode = LineNumberRestartMode.RestartPage;
pageSetup.LineNumberDistanceFromText = 50.0d;

// LineNumberCountBy is set to 3, so every line whose number is a multiple of 3
// will display that line number to the left of the text
for (int i = 1; i <= 25; i++)
    builder.Writeln($"Line {i}.");

// The line counter will skip any paragraph with this flag set to true
// Normally, the number "15" would normally appear next to this paragraph, which says "Line 15"
// Since we set this flag to true and this paragraph is not counted by numbering,
// number 15 will appear next to the next paragraph, "Line 16", and from then on counting will carry on as normal
// until it will restart according to LineNumberRestartMode
doc.FirstSection.Body.Paragraphs[14].ParagraphFormat.SuppressLineNumbers = true;

doc.Save(ArtifactsDir + "PageSetup.LineNumbers.docx");

ExpandedSee Also