@Test public void testPDFThumbnailProvider() throws IOException { log.info("testPDFThumbnailProvider"); PdfThumbnailProvider ptp = new PdfThumbnailProvider(); assertNotNull(ptp.getThumbnail(pdfFile)); }
@Override public InputStream getThumbnail(Resource resource) throws IOException { try (PDDocument document = PDDocument.load(resource.adaptTo(InputStream.class))) { PDFRenderer pdfRenderer = new PDFRenderer(document); BufferedImage bim = pdfRenderer.renderImageWithDPI(0, 300, ImageType.RGB); ByteArrayOutputStream os = new ByteArrayOutputStream(); ImageIO.write(bim, "jpeg", os); return new ByteArrayInputStream(os.toByteArray()); } }
PdfThumbnailProvider implements ThumbnailProvider { @Override public InputStream getThumbnail(Resource resource) throws IOException { try (PDDocument document = PDDocument.load(resource.adaptTo(InputStream.class))) { PDFRenderer pdfRenderer = new PDFRenderer(document); BufferedImage bim = pdfRenderer.renderImageWithDPI(0, 300, ImageType.RGB); ByteArrayOutputStream os = new ByteArrayOutputStream(); ImageIO.write(bim, "jpeg", os); return new ByteArrayInputStream(os.toByteArray()); } } }
PdfThumbnailProvider implements ThumbnailProvider { @Override public InputStream getThumbnail(Resource resource) throws IOException { try (PDDocument document = PDDocument.load(resource.adaptTo(InputStream.class))) { PDFRenderer pdfRenderer = new PDFRenderer(document); BufferedImage bim = pdfRenderer.renderImageWithDPI(0, 300, ImageType.RGB); ByteArrayOutputStream os = new ByteArrayOutputStream(); ImageIO.write(bim, "jpeg", os); return new ByteArrayInputStream(os.toByteArray()); } }  }
PdfThumbnailProvider implements ThumbnailProvider { @Override public InputStream getThumbnail(Resource resource) throws IOException { try (PDDocument document = PDDocument.load(resource.adaptTo(InputStream.class))) { PDFRenderer pdfRenderer = new PDFRenderer(document); BufferedImage bim = pdfRenderer.renderImageWithDPI(0, 300, ImageType.RGB); ByteArrayOutputStream os = new ByteArrayOutputStream(); ImageIO.write(bim, "jpeg", os); return new ByteArrayInputStream(os.toByteArray()); } }  @Override boolean applies(Resource resource); @Override InputStream getThumbnail(Resource resource); }
PdfThumbnailProvider implements ThumbnailProvider { @Override public InputStream getThumbnail(Resource resource) throws IOException { try (PDDocument document = PDDocument.load(resource.adaptTo(InputStream.class))) { PDFRenderer pdfRenderer = new PDFRenderer(document); BufferedImage bim = pdfRenderer.renderImageWithDPI(0, 300, ImageType.RGB); ByteArrayOutputStream os = new ByteArrayOutputStream(); ImageIO.write(bim, "jpeg", os); return new ByteArrayInputStream(os.toByteArray()); } }  @Override boolean applies(Resource resource); @Override InputStream getThumbnail(Resource resource);  }