This short guide assists you in setting the paragraph formatting in Word using C#. It has the details to set the IDE, a list of steps, and a sample code for changing the MS Word paragraph formatting using C#. It will explain various properties and demonstrate the customization of the paragraph format, borders, and style.
Steps for Setting Paragraph Writing Format using C#
- Set the IDE to use Aspose.Words for .NET to format the text
- Create a new Word file using the Document class for setting paragraph format
- Create a DocumentBuilder class object using the above Word document
- Set indentation and alignment properties in the paragraph format
- Set paragraph border and font settings
- Add some text for checking the above paragraph formatting
- Save the new Word file with formatted text
These steps explain how to set Word document paragraph formatting using C#. Create a new Word document, attach a DocumentBuilder object, and access the ParagraphFormat property for setting alignment, left indent, right indent, and space after. Similarly, you may set the borders and font properties such as size, color, and Bold.
Code to Set Microsoft Word Paragraph Formatting using C#
This code segment demonstrates indenting paragraphs using C#. When we create the DocumentBuilder object for the document, we get access to all its properties, such as the ParagraphFormat. You may also set the page setup, alignment, line spacing, page breaks, shading, word wrapping, and even clear the formatting with one command if required.
This article has guided us in setting the formatting of a new or an existing Word file. If you want to remove the headers and footers of a Word file, refer to the article on Remove header and footer in Word using C#.