In Java PDF to Image Library, the DPI is set to 72 as default. In many cases, you want to set higher resolution to get more clearimage(jpg/jpeg, png, bmp, gif and single page tiff) from PDF document.What's more, you can also set the wanted image size directly, then each image getting from PDF is in the input size.
import com.pqscan.pdftoimage.PDFDocument; import javax.imageio.ImageIO; import java.awt.image.BufferedImage; import java.io.File; public class CustomizeImageSize { public static void main(String[] args) { try { //create an instance of PDFDocument object PDFDocument doc = new PDFDocument(); //load PDF document doc.loadPDF("f:/Sample.pdf"); int pageCount = doc.getPageCount(); for(int i = 0; i < pageCount; i++) { //render image in target size BufferedImage image = doc.toImage(i,100,200); //save specific size image ImageIO.write(image,"jpg", new File("output"+i+".jpg")); } } catch (Exception e) { e.printStackTrace(); } } }