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

Free Support Forum - aspose.com

Need to ignore comments in getText() in paragraph

Hi Team,

I need to extract paragraph text, while extracting the text, comments also extracting. Any solution to ignore comment text please?

@kkumaranil485 You can use code like the following to ignore comments:

Document doc = new Document(@"C:\Temp\in.docx");
Paragraph para = doc.FirstSection.Body.FirstParagraph;

StringBuilder builder = new StringBuilder();
foreach (Node child in para.ChildNodes)
    if (child.NodeType != NodeType.Comment)


Alternatively, you can implement DocumentVisitor and create your own TXT exporter.

The above solution works great. Thanks for the support.