Free Support Forum - aspose.com

Count the number of images

Hi Team,

how to calculate the number of images present in the word document and print the count of images.please kindly help me to get number of shapes in a document .

source:sample.zip (1.1 MB)

Thanks & regards,
priyanga G

@priyanga,

An image is represented by Shape object in Aspose.Words and you can try something like below to get number of images in document:

CODE:

Aspose.Words.Document doc = new Aspose.Words.Document("Template.doc");
int imgCount = 0;
foreach (Aspose.Words.Drawing.Shape shape in doc.GetChildNodes(Aspose.Words.NodeType.Shape, true))
{
       if (shape.HasImage)
           imgCount++;
}