2
將所有PDF頁面轉換爲java中的單個圖像
我有一個700KB的pdf文件,我想將它轉換爲縮小大小的單個圖像。我使用PDFBox的將所有PDF頁面轉換爲java中的單個圖像
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.
能否請您給我提供了一些解決方案 –