We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Left allignment to paragraphs

Hi there,

I was using the following peace of code to apply left allignment for all the paragraphs in a document.

Document doc=new Document("//MyTestDoc.doc");
ParagraphCollection pc = doc.GetChildNodes(NodeType.Paragraph, true);
int i=0;
foreach(Paragraph p in pc)

but, unfortunately this was not working for me. please suggest me how to set left allignment for all paragraphs in a document.


Thanks for your inquiry. Please try using the following code:

Document doc = new Document("in.doc");
NodeCollection paragraphs = doc.GetChildNodes(NodeType.Paragraph, true);
foreach (Paragraph paragraph in paragraphs)
    paragraph.ParagraphFormat.Alignment = ParagraphAlignment.Left;

Best regards,

Hi Andrey,

Thanks for your response, the above code was working fine for me, but some of the paragraphs are under styles, means left spacing/after spacing, left indent… such type of properties are applied to paragraphs. these paragraphs are not going to extreme left.

So could you please suggest me how to remove the formatting of paragraphs applied by styles or any way to achieve this.

Hi Srinu,

Thanks for your inquiry. Could you please attach your input document here for testing? I will check the problem on my side and provide you more information.

Best regards,