public String convertPdfPagesToImages(File file, String outputImageDir)
{
PDDocument document = null;
try
{
document = PDDocument.load(file);
PDFRenderer pdfRenderer = new PDFRenderer(document);
for (int page = 0; page < document.getNumberOfPages(); ++page)
{
BufferedImage bim = pdfRenderer.renderImageWithDPI(page, 300,ImageType.RGB);
ImageIOUtil.writeImage(bim, page+"- output.jpg", 300);
}
document.close();
}
catch (IOException e)
{
e.printStackTrace();
return null;
}
return "";
}