Articles in this section
Category / Section

How is it possible to apply "No Paragraph Space" option to a Word document in ASP.NET WebForms?

3 mins read

Microsoft Word let the user to apply “No Paragraph Space” option to the entire Word document. The same could be achieved using DocIO also. The “No Paragraph Space” option should have the following properties along with it.

Property Name

Value

Before Spacing

0

After Spacing

0

Line Spacing

Single



In Microsoft Word you shall find this option from below location.
Go to Design Ribbon -> Click down arrow of “Paragraph Spacing” under “Document Formatting” -> click “No Paragraph Space”. When you choose this option, the above properties will be applied to the “Normal” style and it will be reflected on the paragraphs which are applied with “Normal” style. You shall achieve same using DocIO by applying above property to the “Normal” style.

Please refer the below screen shot to set “No Paragraph Space” option in Microsoft Word:



Limitations:
If the any paragraphs are applied with any direct formatting, then that will be considered rather that the definitions from “Normal” style, according to Microsoft Word document specification.

Kindly use the below code to set “No Paragraph Space” option to the Normal style using DocIO.
C#:

//Loading Word document
WordDocument document = new WordDocument("filename.docx");//Gets the normal style which is base of other styles
WParagraphStyle style = document.Styles.FindByName("Normal") as WParagraphStyle;
//Sets before spacing value
style.ParagraphFormat.BeforeSpacing = 0;
//Sets after spacing value
style.ParagraphFormat.AfterSpacing = 0;
//The below two lines of code sets line spacing single. The line spacing rule "Multiple" with value 12 sets the line spacing "Single"
style.ParagraphFormat.LineSpacingRule = Syncfusion.DocIO.LineSpacingRule.Multiple;
style.ParagraphFormat.LineSpacing = 12;
//Saves the Word document
document.Save("filename.docx");

VB:

Dim document As New WordDocument("filename.docx")'Gets the normal style which is base of other styles
Dim style As WParagraphStyle = TryCast(document.Styles.FindByName("Normal"), WParagraphStyle)
'Sets before spacing value
style.ParagraphFormat.BeforeSpacing = 0
'Sets after spacing value
style.ParagraphFormat.AfterSpacing = 0
'The below two lines of code sets line spacing single. The line spacing rule "Multiple" with value 12 sets the line spacing "Single"
style.ParagraphFormat.LineSpacingRule = Syncfusion.DocIO.LineSpacingRule.Multiple
style.ParagraphFormat.LineSpacing = 12'Saves the Word document
document.Save("filename.docx");

Note:

A new version of Essential Studio for ASP.NET is available. Versions prior to the release of Essential Studio 2014, Volume 2 will now be referred to as a classic versions.The new ASP.NET suite is powered by Essential Studio for JavaScript providing client-side rendering of HTML 5-JavaScript controls, offering better performance, and better support for touch interactivity. The new version includes all the features of the old version, so migration is easy.

The Classic controls can be used in existing projects; however, if you are starting a new project, we recommend using the latest version of Essential Studio for ASP.NET. Although Syncfusion will continue to support all Classic Versions, we are happy to assist you in migrating to the newest edition.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls. If you have any queries or require clarifications, please let us know in the comments section below.

You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied