This quick guide explains how to add sections to Word document in C#. It provides settings for the IDE, shares a list of programming instructions, and a sample code demonstrating how to insert a section break in Word using C#. You will get a step-by-step understanding of the process in the given sample code and create a Word file with multiple sections in it.
Steps to Add Section Break in Word using C#
- Set the environment to use Aspose.Words for .NET for adding section breaks
- Load the license to avail the full product features
- Create a Document class object
- Create a DocumentBuilder class object and link it with the above-mentioned Document object
- Write some text content in the new file using the document builder
- Insert a section break through the document builder
- Set page orientation for the new section and write some text in the new section
- Save the Word file
The above-mentioned steps explain how to add section break in Word using C#. Create the Document and DocumentBuilder class objects, set the Document object in the DocumentBuilder, and write text using the builder. Insert a break of SectionBreakNewPage type with the builder, set page orientation for the new section, add more text to the new section, and save the Word file.
Code for Adding Section Break using C#
This code has demonstrated how to do section break in Word using C#. You can apply various types of section breaks, such as SectionBreakContinuous, SectionBreakOddPage, and SectionBreakEvenPage, to list a few. Options are also available to load an existing Word file with contents in it, find the position, and add a new section break as per your requirements.
This article has taught us how to add a section break in a Word file. To detect and verify digital signatures, refer to the article Verify Digital Signature in Word Document using C#.