Remove equations from the document causes issue

Hi @tahir,

Thanks for your update .I am able extract the group shape images.Thanks for your help.still some of the images not extracted from the word document.please let me know how to extract those images.

The source code is NewAip(1).zip (46.3 KB)
The input document is
Test.zip (2.7 MB)
Thanks & Regards
priyanga G

@priyanga,

Thanks for your inquiry. Could you please share the page numbers of input document that have group shapes and are not exported? We will investigate the issue and provide you more information on this.

Hi @tahir.manzoor

Thank you very much fro your timely reply.The page number is 40.Once the group shape image is arrived the extraction is getting failed.Please,help me how to resolve it.

Thanks and regards,
priynaga G

@priyanga,

Thanks for sharing the detail. The shared page does not contain the GroupShape. It has shapes inside table. Please check the Aspose.Words’ DOM image for detail. You can use the same approach to export the Table in output document. DOM.png (12.5 KB)

Thank you very much for providing the solution.

Thanks
&
Regards,

Priyanga.G

@priyanga,

Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.

Hi tahir,

Thanks for all help and support.The requirement is How to get fig caption for group shape and print the name along with filename.please help me to get fig caption .

Thanks & regards
priyanga G

@priyanga,

Thanks for your inquiry. In this case, we suggest you following solution.

  1. Iterate through all Shape nodes.

  2. If the ancestor node of Shape is Table, export the table into new document.

  3. If the ancestor node of Shape is GroupShape, export GroupShape to new document.

  4. if the next sibling node of Shape’s parent node is Paragraph and it contains the text “Figure”, export the Shape’s paragraph and its next sibling to new document.

     Document doc = new Document(MyDir + "test.docx");
     DocumentBuilder builder = new DocumentBuilder(doc);
     int i = 1;
     NodeCollection shapes = doc.getChildNodes(NodeType.SHAPE, true);
     for (Shape shape : (Iterable<Shape>) shapes)
     {
         if(shape.hasChart() || shape.hasImage())
         {
             if (shape.getAncestor(NodeType.TABLE) != null)
             {
                 Document dstDoc = new Document();
                 NodeImporter importer = new NodeImporter(doc, dstDoc, ImportFormatMode.KEEP_SOURCE_FORMATTING);
                 Node newNode = importer.importNode(shape.getAncestor(NodeType.TABLE), true);
                 dstDoc.getFirstSection().getBody().appendChild(newNode);
                 dstDoc.save(MyDir + "output"+i+".docx");
                 i++;
             }
    
         if (shape.getAncestor(NodeType.GROUP_SHAPE) != null)
         {
             Document dstDoc = new Document();
             NodeImporter importer = new NodeImporter(doc, dstDoc, ImportFormatMode.KEEP_SOURCE_FORMATTING);
             Node newNode = importer.importNode(shape.getAncestor(NodeType.GROUP_SHAPE), true);
             dstDoc.getFirstSection().getBody().getFirstParagraph().appendChild(newNode);
             dstDoc.save(MyDir + "output"+i+".docx");
             i++;
         }
    
         Node node = shape.getParentNode().getNextSibling();
         //Modify this condition according to your requirement
         if(node != null && node.getNodeType() == NodeType.PARAGRAPH
                 && node.toString(SaveFormat.TEXT).contains("Figure"))
         {
             Document dstDoc = new Document();
             NodeImporter importer = new NodeImporter(doc, dstDoc, ImportFormatMode.KEEP_SOURCE_FORMATTING);
             Node newNode = importer.importNode(shape.getParentParagraph(), true);
             dstDoc.getFirstSection().getBody().appendChild(newNode);
    
             newNode = importer.importNode(shape.getParentParagraph().getNextSibling(), true);
             dstDoc.getFirstSection().getBody().appendChild(newNode);
    
             dstDoc.save(MyDir + "output"+i+".docx");
             i++;
         }
     }}