Extract table from the document based on Figure caption using Java

HI Team
Here i had shared a document which in table contains label images.I can’t able extract those kind of scenario could you please help to extract those images.
Input::input.zip (3.9 MB)
output::output.zip (801.5 KB)

@jan.kathir

Please use the following code example to get the desired output. Hope this helps you.

Document doc = new Document(MyDir + "Revised Manuscript.docx");
int i = 1;

for (Paragraph  paragraph : (Iterable<Paragraph>) doc.getChildNodes(NodeType.PARAGRAPH, true))
{
    if(paragraph.toString(SaveFormat.TEXT).trim().startsWith("Figure"))
    {
        Node node = paragraph.getPreviousSibling();
        if(node.getNodeType() == NodeType.TABLE)
        {
            Document dstDoc = new Document();
            NodeImporter importer = new NodeImporter(doc, dstDoc, ImportFormatMode.KEEP_SOURCE_FORMATTING);
            Node newNode = importer.importNode(node, true);
            dstDoc.getFirstSection().getBody().appendChild(newNode);

            dstDoc.save(MyDir + "output"+i+".pdf");
            i++;
        }
    }
 }