Free Support Forum - aspose.com

Image captions

I know how to find all the images (via Shape nodes) in a document. What would be the best method to extract the captions for each of these?

- Todd

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. Captions are inserted right below of shapes. So I think that you can try getting text from the paragraph after shape. For example see the following code.

Document doc = new Document(@"Test141\in.doc");

NodeCollection shapes = doc.GetChildNodes(NodeType.Shape, true, false);

foreach (Shape shape in shapes)

{

string caption = shape.ParentParagraph.NextSibling.ToTxt();

}

I hope this could help you.

Best regards.