We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

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)<o:p></o:p>

{

// 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,