Split images

Hi Team,

I want to split the two images. In this case, Figure 11 was anchored with Figure 12. Is it possible to separate two different docx files?

Input: Input.docx (77.3 KB)
Excepted Output: ExceptedOutput.zip (64.2 KB)

Regards,
Mahi

@Mahi39 The problem with this document is that images in it are not actually images. They are constructed with a bunch of floating shapes. So the only way to split them is to copy paragraphs that contain these floating shapes:

Document doc = new Document("C:\\Temp\\in.docx");
    
// Get paragraphs with the shapes.
// first "image"
Paragraph p3 = doc.getFirstSection().getBody().getParagraphs().get(2);
Paragraph p4 = doc.getFirstSection().getBody().getParagraphs().get(3);
// second "image"
Paragraph p5 = doc.getFirstSection().getBody().getParagraphs().get(4);
    
Document doc1 = (Document)doc.deepClone(false);
doc1.ensureMinimum();
doc1.getFirstSection().getBody().appendChild(doc1.importNode(p3, true, ImportFormatMode.USE_DESTINATION_STYLES));
doc1.getFirstSection().getBody().appendChild(doc1.importNode(p4, true, ImportFormatMode.USE_DESTINATION_STYLES));
doc1.save("C:\\temp\\out1.docx");
        
Document doc2 = (Document)doc.deepClone(false);
doc2.ensureMinimum();
doc2.getFirstSection().getBody().appendChild(doc2.importNode(p5, true, ImportFormatMode.USE_DESTINATION_STYLES));
doc2.save("C:\\temp\\out2.docx");

Unfortunately, there is no general solution for such documents.