Search code examples
c#.netasp.net-mvc-4aspose

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


Solution

  • 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;                            
                            }
                        }
                     }