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

Free Support Forum - aspose.com

Cannot compile example

I cannot compile this example: https://docs.aspose.com/pdf/java/convert-pdf-to-images-format/

The error message is:

ConvertPdf.java:18: expected

jpegDevice.process(pdfDocument.getPages().get_Item(1), imageStream);

^

ConvertPdf.java:20: expected

imageStream.close();

^

I set the classpath as follows:

export -s CLASSPATH=/home/hp/java/aspose-pdf-jdk14.jar

This is my sourcecode:

import java.io.*;

class ConvertPdf {

//open document

com.aspose.pdf.Document pdfDocument = new com.aspose.pdf.Document(“input.pdf”);

// create stream object to save the output image

java.io.OutputStream imageStream = new java.io.FileOutputStream(“Converted_Image.jpg”);

//create JPEG device with specified attributes

//Quality [0-100], 100 is Maximum

//create Resolution object

com.aspose.pdf.devices.Resolution resolution = new com.aspose.pdf.devices.Resolution(300);

//create JpegDevice object where second argument indicates the quality of resultant image

com.aspose.pdf.devices.JpegDevice jpegDevice = new com.aspose.pdf.devices.JpegDevice(resolution, 100);

//convert a particular page and save the image to stream

jpegDevice.process(pdfDocument.getPages().get_Item(1), imageStream);

//close the stream

imageStream.close();

}

Hi there,


Thanks for your inquiry. I am afraid I am unable to replicate the issue, while testing the scenario with Aspose.Pdf for Java 9.1.0. Please confirm your Jar version, so we will try to replicate the issue and guide you accordingly.

We are sorry for the inconvenience caused.

Best Regards,

Version 1.5.0:

> java -version

java version “1.5.0”

Java™ 2 Runtime Environment, Standard Edition (build pap32devifx-20130702 (SR16 FP3 ))

IBM J9 VM (build 2.3, J2RE 1.5.0 IBM J9 2.3 OS/400 ppc-32 j9vmap3223sr16ifx-20130613 (JIT enabled)

J9VM - 20130611_151893_bHdSMr

JIT - 20121221_30553_r8

GC - 20120911_AA)

JCL - 20130702

$

Hi there,


Thanks for sharing additional information. We have logged an investigation ticket as PDFNEWJAVA-34304 for further investigation and resolution. We will keep you updated about the issue resolution progress.

We are sorry for the inconvenience caused.

Best Regards,

Hi there,


Thanks for your patience. Please note it is recommended to use JDK 1.6 or higher as Aspose.Pdf does not currently support versions of JDK 1.5 and below.

We are sorry for the inconvenience caused.

Best Regards,