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

Free Support Forum - aspose.com

While creating jpg form the pptx it's destroying the chart

Hi Team,

I am using the aspose-slide 19.12. While creating jpeg from pptx it’s destroying the chart.
Please refer attached ppt & jpg.image issue.zip (1.0 MB)
Is there any way to resolve this issue?

@Shree995,

I have observed the image shared by you and request you to please first try using latest Aspose.Slides 20.2 on your end. In case there is still an issue then please share the working sample code with us that is reproducing issue on your end.

Hi @mudassir.fayyaz

As per your suggestion, I also try the latest version 20.2 in this also I am not getting the right image.
Here is the sample code
`package dev.webfactory;

import com.aspose.slides.AsposeLicenseException;
import com.aspose.slides.ISlide;
import com.aspose.slides.License;
import com.aspose.slides.Presentation;

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

public class Main {

static String downloadPath = "/convert"; // path of the folder which contaning the pptx files.
static String inputFilename = "";
static String outputFilename = "";

public static void main(String[] args) throws Exception {

    File dir1 = new File(downloadPath);
    File[] dirContents = dir1.listFiles();
    System.out.println("Download Path: " + downloadPath);
    System.out.println(dirContents.length);
    for (File dirContent : dirContents) {
        if (dirContent.getName().endsWith(".pptx")) {
            thumbnail(dirContent, downloadPath);
        } else if (dirContent.isDirectory() && !dirContent.getName().equals("img")) {                
            String newpath = downloadPath + "/" + dirContent.getName();
            System.out.println("New download path" + newpath);
            File dir3 = new File(newpath);
            File[] dirContents1 = dir3.listFiles();
            for (File dirContent1 : dirContents1) {
                if (dirContent1.getName().endsWith(".pptx")) {
                    thumbnail(dirContent1, newpath);
                }
            }
        }
    }
}

private static void thumbnail(File dirContent, String downloadPath) throws IOException {

    inputFilename = downloadPath + "/" + dirContent.getName();
    outputFilename = downloadPath + "/img/" + dirContent.getName().replace(".pptx", ".jpg");
    System.out.println("Input file name " + inputFilename);
    System.out.println("Output file name " + outputFilename);

    File temp = new File(inputFilename);
    if (temp.exists()) {
        String[] path = outputFilename.split("/");
        String fileName = path[path.length - 1];

        String directory = outputFilename.substring(0, (outputFilename.length() - fileName.length() - 1));
        activateLicense(System.getProperty("user.dir") + "/Aspose.Slides-new.lic");

        Presentation presentation = new Presentation(inputFilename);
        ISlide slide = presentation.getSlides().get_Item(0);
        BufferedImage image = slide.getThumbnail(1f, 1f);
        presentation.dispose();
        try {

            File file = new File(outputFilename);
            File dir = new File(directory);
            if (!dir.exists()) {
                dir.mkdirs();
            }
            ImageIO.write(image, "jpg", file);
            image = null;
        } catch (IOException e) {
            System.out.println(e.getMessage());
        }
    }
}

private static void activateLicense(String filename) throws IOException {

    FileInputStream stream = null;
    try {
        stream = new FileInputStream(filename);
        License license = new License();
        license.setLicense(stream);
    } catch (AsposeLicenseException | FileNotFoundException ex) {
        System.out.println(ex.toString());
    } finally {
        if (stream != null) {
            stream.close();
        }
    }
}

}
`

@Shree995,

I have worked with the issue share by you and have created an issue with ID SLIDESJAVA-38069 in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once the issue will be resolved.

Thanks @mudassir.fayyaz

@Shree995,

You are welcome.

The issues you have found earlier (filed as SLIDESJAVA-38069) have been fixed in this update.