How to insert section break in a document

In Microsoft Word, you can easily split the document into sections by insert a section break in the place where you want, thus allowing you to apply different formatting or layout options to those sections. Section breaks in Microsoft Word can be a godsend if you need to perform any of the following tasks:

  • Use page numbering that starts at 1 for each section of your document (for example, different chapters in the same document).
  • Display text in two columns for only a portion of your document and then return to the default one column afterwards.
  • Display different header and footer information for different parts of your document.

This article demonstrates an easy solution to insert section break to split document into sections in C#, VB.NET via Spire.Doc for .NET. The following screenshot shows result after inserting Word page break.

Insert section break in a document

Spire.Doc for .NET provides Paragraph.InsertSectionBreak method for customers to insert break easily in Word. The overload, which should be passed to this method, is SectionBreakType (enum-type). There are five section break options offered by Spire.Doc for .NET such as EvenPage, NewColumnNewPage, NoBreak, OddPage. Download and install Spire.Doc for .NET and follow the code blow to insert section break behind the specified paragraph.

using Spire.Doc;
using Spire.Doc.Documents;
namespace InsertSectionBreak
{
    class Program
    {
        static void Main(string[] args)
        {
            Document doc = new Document();
            doc.LoadFromFile("E-iceblue Technology_new.docx");
            doc.Sections[0].Paragraphs[0].InsertSectionBreak(SectionBreakType.NoBreak);
            doc.SaveToFile("SectionBreak.docx", FileFormat.Docx);
        }
    }
}