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

Free Support Forum - aspose.com

Convert PDF to JPG in Java using Aspose.PDF | Error in processing graphic objects

public static void main(String[] args) {
String inputFileName = Paths.get(“aaa.pdf”).toString();
Document pdfDocument = new Document(inputFileName);

    try {
        for (int pageCount = 1; pageCount <= pdfDocument.getPages().size(); pageCount++) {
            // Create stream object to save the output image
            String outputFilePath = "aaa.jpg";
            java.io.OutputStream imageStream = new java.io.FileOutputStream(outputFilePath);
            Resolution resolution = new Resolution(300);
            JpegDevice JpegDevice = new JpegDevice(resolution);
            JpegDevice.process(pdfDocument.getPages().get_Item(pageCount), imageStream);
            imageStream.close();
        }
    } catch (FileNotFoundException e) {

    } catch (IOException e) {

    } finally {
        if (pdfDocument != null) {
            pdfDocument.dispose();
        }
    }

}

@zyx

We were able to reproduce the OOM Exception at our end while testing the scenario with 21.6 version of the API. Hence, an issue as PDFJAVA-40666 has been logged in our issue tracking system for the sake of correction. We will look into its details and let you know once it is fixed. Please be patient and spare us some time.

We are sorry for the incovnenience.