Quantcast
Channel: Aspose.Pdf Product Family
Viewing all articles
Browse latest Browse all 3131

Cannot compile example

$
0
0
I cannot compile this example: http://www.aspose.com/docs/display/pdfjava/Convert%20PDF%20pages%20to%20JPEG%20Image

The error message is:
  ConvertPdf.java:18: <identifier> expected                                      
  jpegDevice.process(pdfDocument.getPages().get_Item(1), imageStream);           
                    ^                               
   ConvertPdf.java:20: <identifier> 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();
}

Viewing all articles
Browse latest Browse all 3131

Trending Articles