Open Source libraries for PDF to image conversion

2019-05-30 04:22发布

问题:

Possible Duplicate:
Export PDF pages to a series of images in Java

Please suggest some good java libraries which can be used for a PDF file to image conversion. I tried using PDFBox: http://pdfbox.apache.org/ but after conversion to image most of my text from the pdf file was garbled in the image. It read a 'T' as a 'Y' a 'C' as a '#' and so on.

Following is the code snippet I used for the same:

PDDocument document = null;  
document = PDDocument.load( pdfFile );  
List  pages = document.getDocumentCatalog().getAllPages();  
for( int i=startPage-1; i<endPage && i<pages.size(); i++ )  
{  
  try  
  {  
    PDPage page = (PDPage)pages.get( i );  
    BufferedImage  image = page.convertToImage();  
  }  
}  
document.close(); 

I guess it is some issue that they have with rendering fonts. In case u think I might have missed something out while using PDFBox please let me know.

Please suggest any other alternatives as well.

I have tried using jPedal: http://www.jpedal.org/ which works out fine but its not free so please suggest about all good alternatives on this.

回答1:

Try icePDF