// Load document
Document doc = new Document("input.pdf");

for (int i = 0; i < doc.getPages().size(); i++) {
	// Get page
	Page page = doc.getPages().get_Item(i);

	// Create file stream for image
	FileOutputStream imageStream = new FileOutputStream("Thumbnails_" + page.getNumber() + ".jpg");

	// Create resolution object
	Resolution resolution = new Resolution(300);

	// Create an instance of JpegDevice and set height, width, resolution, and
	// quality of image
	JpegDevice jpegDevice = new JpegDevice(45, 59, resolution, 100);

	// Convert a page and save the image to stream
	jpegDevice.process(page, imageStream);

	// Close stream
	try {
		imageStream.close();
	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
}