We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Extracting chart object

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 the output is empty .please let me know.how to work it for chart object.’
I have tried the property of shape.has chart().
The show cases are nearing .please help me to solve the issue.

the source code Test.zip (41.0 KB)

the input test.zip (37.8 KB)

the expected output
actualoutput.zip (36.6 KB)



Thanks for your inquiry. Please use the following code example to get the desired output.

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)
    NodeCollection shapes = paragraph.getChildNodes(NodeType.SHAPE, true);
    if (paragraph.toString(SaveFormat.TEXT).trim().contains("Figure") && shapes.getCount() > 0)
        //Remove the text from the paragaph node
        paragraph.getChildNodes(NodeType.RUN, false).clear();

        Document dstDoc = new Document();
        NodeImporter importer = new NodeImporter(doc, dstDoc, ImportFormatMode.KEEP_SOURCE_FORMATTING);
        Node newNode = importer.importNode(paragraph, true);
        dstDoc.save(MyDir + "output"+i+".docx");

Hi @tahir manzoor,

Thank you very much.

The output is fine.

Thanks a lot.

priyanga G