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

Free Support Forum - aspose.com

Get Figure Caption from Docx

Hi team,

Is it possible to get the Figure Caption(Text after the Image) in docx using aspose.words?

Thanks in Advance

Priya Dharshini J P

Hi Priya,

Thanks for your inquiry. The figure caption (text after the image) is inside Paragraph node. You can get this text by using Paragraph.toString(SaveFormat.TEXT) method. Please check the following code snippet. Hope this helps you.

<pre style=“background-color: rgb(255, 255, 255); font-family: “Courier New”; font-size: 9pt;”>Document doc = new Document(MyDir + “Sample_FigCap.docx”);
Shape shape = (Shape)doc.getChild(NodeType.SHAPE, 1, true);

if(shape.getParentParagraph().getNextSibling() != null
&& shape.getParentParagraph().getNextSibling().getNodeType() == NodeType.PARAGRAPH)

Thanking you for the help @tahir.manzoor

Priya Dharshini J P