How to check document has header with image using aspose.words?

how to check document has header with image using aspose.words?

Hi,

Thanks for your inquiry. You can try something like below:

public static bool HasHeaderAnyImage(Document doc)
{
    // An image can be represented by Shape or DrawingML object
    NodeCollection shapes = doc.GetChildNodes(NodeType.Shape, true);
    NodeCollection drawingMLs = doc.GetChildNodes(NodeType.DrawingML, true);
    // search through all Shapes for images and return if an image is found in header/footer
    foreach(Shape shape in shapes)
    {
        if (shape.ShapeType == ShapeType.Image)
        {
            if (shape.GetAncestor(NodeType.HeaderFooter) != null)
                return true;
        }
    }
    // search through all DrawingML objects for images and return if an image is found in header/footer
    foreach(DrawingML drawingML in drawingMLs)
    {
        if (drawingML.HasImage)
        {
            if (drawingML.GetAncestor(NodeType.HeaderFooter) != null)
                return true;
        }
    }
    return false;
}

I hope, this will help.

Best Regards,