如何使用Aspose.Word

时间:2017-01-31 06:34:37

标签: c# .net asp.net-mvc-4 aspose

如何在Aspose.Word生成的word文档中获取所有已卸载的图像。像这样的图像。 Unloaded Image

1 个答案:

答案 0 :(得分:3)

我已经解决了我的问题。我在这里发布我的答案,也许这对其他人有帮助。

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