Free Support Forum - aspose.com

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

Hi

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 document.so 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?

Hello

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,

Hi,

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

Thanks ,
Dhanasekhar

Hi

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;

}

doc.Save("C:\\Temp\\out.docx");

Hope this helps.

Best regards,