How to remove paragraphs from word page

Hi Team,

How to remove all paragraphs from word page except Shapes or Images.
I just want to keep only images or shapes in word page and remove all other paragraphs or text.


Generally, you can use the following Aspose.Words code to remove all paragraphs from Word document except the Shapes or Images:

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

foreach(Paragraph para in doc.GetChildNodes(NodeType.Paragraph, true))
    if (para.GetChildNodes(NodeType.Shape, true).Count == 0)


In case the problem still remains, please ZIP and attach the following resources here for testing:

  • Your simplified input Word document (you want to remove Paragraphs from)
  • Aspose.Words generated output DOCX file showing the undesired behavior (if any)
  • Your expected DOCX file showing the desired output. You can create this document by using MS Word.

As soon as you get these pieces of information ready, we will start further investigation into your issue and provide you code to achieve the same by using Aspose.Words. Thanks for your cooperation.