Asad Raza
Asad Raza

Reputation: 89

How can I get all unloaded images in word document using Aspose.Word

How can I get all unloaded images in the word document which is generated by Aspose.Word. Images like this. Unloaded Image

Upvotes: 4

Views: 156

Answers (1)

Asad Raza
Asad Raza

Reputation: 89

I have solved my problem. I am posting my answer here, maybe it's helpful to someone other.

    var doc = new Document();
    var shapeCollection = doc.GetChildNodes(Word.NodeType.Shape, true);

                // getting all images from Word document. 
                foreach (Shape shape in shapeCollection)
                {                        
                    if (shape.ShapeType == ShapeType.Image)
                    {
                       //Unloaded image alwasy have 924 imagebytes
                        if (shape.ImageData.ImageBytes.Length == 924)
                        {
                            shape.Width = 72.0;
                            shape.Height = 72.0;                            
                        }
                    }
                 }

Upvotes: 3

Related Questions