Convert Chart to Image in Java

In some scenarios, working with PowerPoint files becomes a challenge when they contain huge amounts of data including graphical data such as charts. However, graphical data is more useful than textual so extracting charts from PPT/PPTX and saving them as images can fulfill your purpose. Then, you can quickly open and walk through those extracted charts to learn about the data. So, this blog post helps you convert chart to image in Java programmatically using Aspose.Slides for Java. Therefore, go through this guide to learn how to extract charts from PPTX/PPT files.

The blog post covers the following points:

  1. Data Extraction API Installation
  2. Convert Chart to Image in Java - Code Sample

Data Extraction API Installation

You can visit this installation guide. Now, you can download this JAR file or you may use the following Maven configurations to install Aspose.Slides for Java:

    <name>Aspose Java API</name>
Data Extraction API

Convert Chart to Image in Java - Code Sample

You can follow the steps given below to develop a graph extractor:

  • Define the path to the source PowerPoint file directory.
  • Initialize an instance of the Presentation class with a source PPTX/PPT file.
  • Invoke the addChart method to add a chart to the end of the collection.
  • getImage method returns the shape thumbnail.
  • Invoke the save method to save the chart as a PNG image.

The following code sample shows how to convert chart to image in Java programmatically:

You can see the output in the image below:

Extract Charts From PPTX

Extract Charts From PPTX - Get a Free License

Now, you can get a free temporary license to try this data extraction API without evaluation limitations.

Summing up

We are ending this guide here with the hope that you have learned how to convert chart to image in Java using this data extraction API. In addition, we developed a chart extraction service to extract charts as images from PPT/PPTX files. Further, you can visit the documentation, GitHub repo and API reference to learn more about this Java library. Finally, is writing continually, so stay connected for the latest updates.

Ask a question

You can let us know about your questions or queries on our forum.

See Also