Link

Convert PDF to JPG

JPedal provides several methods to allow the conversion of a PDF file or directory of PDF files into JPG. Java examples use the JpegEncoderOptions classes.

Convert PDF to JPG from Command Line or another language

java -jar jpedal.jar --convert "inputFileOrDir" "outputDir" jpg

Convert PDF to JPG in Java with convenience static method

ConvertPagesToImages.
writeAllPagesAsImagesToDir("inputFileOrDir", "outputDir" , "jpg", 1.33f);

Convert PDF to JPG in Java with control over the image output

ConvertPagesToImages convert = new ConvertPagesToImages("/path/file.pdf");
if (convert.openPDFFile()) {
    try {    
        for (int page = 1; page <= convert.getPageCount(); page++) {
            BufferedImage bi = convert.getPageAsImage(page);            
            File out = new File("/path/to/output/" + page + ".jpg");
            //setters to control output (example with compression)
            JpegEncoderOptions options = new JpegEncoderOptions();
            options.setQuality(90); //Default is 75. No compression is 100
            JDeli.write(bi, options, out);
        }
    } catch (PdfException | IOException e) {
        e.printStackTrace();
    }
}
convert.closePDFfile();

Convert PDF to JPG in Java with a password-protected PDF file

ConvertPagesToImages convert = new ConvertPagesToImages("/path/file.pdf");
convert.setPassword("password"); 
if (convert.openPDFFile()) {
    try {
        for (int page = 1; page <= convert.getPageCount(); page++) {
            BufferedImage bi = convert.getPageAsImage(page);
            File out = new File("/path/to/output/" + page + ".jpg");
            JDeli.write(bi, OutputFormat.JPEG, out); 
        }
    } catch (PdfException | IOException e) { 
        e.printStackTrace(); 
    } 
}
convert.closePDFfile();

If you are looking for upscaling or more complex control over the PDF to JPG conversion, ConvertPagesToHiResImages class has lots of additional options

Still need help? Send us your questions.