在java中将所有PDF页面转换为单个图像
我有一个700KB的pdf文件,我想将它转换为缩小尺寸的单个图像。我在下面尝试过。我正在使用 PDFBox
PDDocument document = PDDocument.loadNonSeq(file,null);
List<PDPage> pages = document.getDocumentCatalog().getAllPages();
int i =0;
for ( PDPage page : pages ) {
BufferedImage image = page.convertToImage();
BufferedImage imageBW = new BufferedImage(image.getWidth(),
image.getHeight(), BufferedImage.TYPE_3BYTE_BGR);
Graphics g = imageBW.getGraphics();
g.drawImage(image, 0, 0, null);
g.dispose();
java.io.File file1 = new
java.io.File(("D:\\FTPUploads\\GuestSupply_"+i+".jpg"));
ImageIO.write(imageBW, "jpg", file1);
i++;
}
But there difference found is only 10 KB and here it created into 2 images (pdf having 2 pages) i need it in single image. Could you please help me out on this.