PDFBox: Problem with converting pdf page into image

Posted by user552910 on Stack Overflow See other posts from Stack Overflow or by user552910
Published on 2010-12-24T01:32:47Z Indexed on 2012/06/10 4:40 UTC
Read the original article Hit count: 236

Filed under:
|
|
|

My mission is pretty simple: converting every single page of a pdf file into images. I tried using icepdf open source version to generate the images but they don't generate the image with the correct font. So I start using PDFBox instead. The code is the following:

PDDocument document = PDDocument.load(new File("testing.pdf"));             
List<PDPage> pages = document.getDocumentCatalog().getAllPages();
for (int i = 0; i < pages.size(); i++) {
 PDPage singlePage = pages.get(i);
 BufferedImage buffImage = convertToImage(singlePage, 8, 12);
 ImageIO.write(buffImage, "png", new File(PdfUtil.DATA_OUTPUT_DIR+(count++)+".png"));
}

The font looks good, but the pictures within the pdf file look fainted out (See the attachment). I look into the source code but I still have no clue how to fix it. Do you guys have any idea what's going on? Please help. Thanks!!

© Stack Overflow or respective owner

Related posts about java

Related posts about image