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();
}
}
}