Posted By

markt22 on 09/27/17


Tagged

PDFBox


Versions (?)

PDFBox: Render first page in a document


 / Published in: Java
 

Opens a PDF Document and renders the first page as an image, which is then saved to file.

  1. /**
  2.  * @param args the command line arguments
  3.  * @throws java.io.IOException
  4.  */
  5. public static void main(String[] args) throws IOException {
  6. File file = new File("");
  7.  
  8. PDDocument doc = PDDocument.load(file);
  9. PDFRenderer pdfRenderer = new PDFRenderer(doc);
  10. BufferedImage image = pdfRenderer.renderImageWithDPI(0, 300);
  11.  
  12. ImageIOUtil.writeImage(image,"", 300);
  13. doc.close();
  14. }

Report this snippet  

You need to login to post a comment.