Handle chart image inside table

Hi Team,
The requirement is extracting the images and saved into new document.For the extraction process using paragraph node and fig caption as keyword. In my code i have separate the image handling in following ways
Section A-handling figures with caption as previous
Section B-handling images with caption as nextsibling
Section C-handling images inside the table
Section D-handling images landscape mode

The input document having chart images inside the table.please let me know how to handle chart images inside the table.

The source code source.zip (8.3 KB)

The input Test.zip (2.7 MB)

The expected output expected output.zip (1.5 MB)

The actual output Actualoutput.zip (1.1 MB)

Thanks in advance
regards,
pria.

@akshayapria,

Thanks for your inquiry. You have shared many output documents. Could you please share some more detail about your query? Please share the page number of input document that contains the table you want to extract. We will then provide you more information about your query along with code.

Hi @tahir,

Thank you very much.

Thanks for your quick feed back.

The page number of table images is pageno-30,31,34.

and also the fig no-1,2,6.

Thanks and regards
Priyanga G

@akshayapria,

Thanks for your inquiry. We already shared similar code example with you in following forum thread.

Following code example shows how to iterate through paragraphs (Fig captions) and extract the table node if it is inside table node.

Document doc = new Document(MyDir + "test.docx");
DocumentBuilder builder = new DocumentBuilder(doc);
int i = 1;
NodeCollection paragraphs = doc.getChildNodes(NodeType.PARAGRAPH, true);
for (Paragraph paragraph : (Iterable<Paragraph>) paragraphs)
{
    if (paragraph.toString(SaveFormat.TEXT).startsWith("Figure") && paragraph.getAncestor(NodeType.TABLE) != null)
    {
        Document dstDoc = new Document();
        NodeImporter importer = new NodeImporter(doc, dstDoc, ImportFormatMode.KEEP_SOURCE_FORMATTING);
        Node newNode = importer.importNode(paragraph.getAncestor(NodeType.TABLE), true);
        dstDoc.getFirstSection().getBody().appendChild(newNode);
        dstDoc.save(MyDir + "output"+i+".docx");
        i++;
    }
}

Hi @tahir.manzoor ,

It’s worked.

Thanks a lot.

regards ,
pria