Fig caption placed parallel

Dear Team
I facing some challenges to extract Fig caption placed parallely .Here i had attached sample input and output so please check and provide solution.
input::input.zip (158.6 KB)
Output::output.zip (157.2 KB)

Thanks
Janani.K

@jan.kathir

To ensure a timely and accurate response, please attach the following resources here for testing:

  • Please attach the expected output Word files that shows the desired behavior.
  • Please create a simple Java application (source code without compilation errors) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we will start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip and upload them.

Hi Team
I had attached expected output already please take it up.
I had attached java file as you requested.Please find the attachment.
Sample code ::CaptionBelow.zip (2.0 KB)

@jan.kathir

Please use the following code example to extract the desired images from the document. Hope this helps you.

Document doc = new Document(MyDir + "08_0105 sample.docx");
int i = 1;
for (Paragraph  paragraph : (Iterable<Paragraph>) doc.getChildNodes(NodeType.PARAGRAPH, true))
{
	if(paragraph.toString(SaveFormat.TEXT).trim().startsWith("Fig") 
			&& paragraph.getPreviousSibling() != null
			&& paragraph.getPreviousSibling().getNodeType() == NodeType.PARAGRAPH
	        && ((Paragraph)paragraph.getPreviousSibling()).getChildNodes(NodeType.SHAPE, true).getCount() > 0 )
	{
	    int replaces = paragraph.deepClone(true).getRange().replace("Fig", "Fig");
	    if(replaces > 1)
	    {
	        for (Shape shape : (Iterable<Shape>) ((Paragraph)paragraph.getPreviousSibling()).getChildNodes(NodeType.SHAPE, true))
	        {
	            Document dstDoc = new Document();
	            NodeImporter importer = new NodeImporter(doc, dstDoc, rtFormatMode.KEEP_SOURCE_FORMATTING);
	            Node newNode = importer.importNode(shape, true);
	            dstDoc.getFirstSection().getBody().getFirstParagraph().appendChild(newNode);
	            dstDoc.save(MyDir + "base_out"+i+".docx");
	            i++;
	        }
	    }
	}	
}