Free Support Forum -

How to set the paragrah format like space before and space after


I am not able to appy the paragraph formates of Word document using c#.

Actually in my application i am getting each para from DB into one new document and then append to the existing where i need to apply the paragraph formate like Space before ,Space after and line space .

i just want to apply to my whole document

Colud you please help me on this?


Thanks for your request. To achieve what you are looking for you should loop through all paragraph inside your document and apply needed formatting.

Best regards,


Thanks for the respose, Could you please provide the sample code for these fuctionality .

Thanks ,


Thanks for your inquiry. Here is code example:

Document doc = new Document("C:\\Temp\\in.docx");

// Get Paragraph Collection

NodeCollection paragraphColl = doc.GetChildNodes(NodeType.Paragraph, true);

// Loop though all Paragraphs

foreach (Paragraph par in paragraphColl)


par.ParagraphFormat.SpaceBefore = 10;



Hope this helps.

Best regards,