From 4d8a948455bbf7ab09e57eb4c24c6fda1bb11c28 Mon Sep 17 00:00:00 2001 From: luccioman Date: Fri, 22 Mar 2019 09:50:30 +0100 Subject: [PATCH] Properly close PDF snapshots loaded with pdfbox library --- source/net/yacy/cora/util/Html2Image.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/net/yacy/cora/util/Html2Image.java b/source/net/yacy/cora/util/Html2Image.java index fa4bd17cf..611f38897 100644 --- a/source/net/yacy/cora/util/Html2Image.java +++ b/source/net/yacy/cora/util/Html2Image.java @@ -348,8 +348,8 @@ public class Html2Image { // convert pdf to jpg using internal pdfbox capability if (convertCmd == null) { - try { - PDDocument pdoc = PDDocument.load(pdf); + try (final PDDocument pdoc = PDDocument.load(pdf);) { + BufferedImage bi = new PDFRenderer(pdoc).renderImageWithDPI(0, density, ImageType.RGB); return ImageIO.write(bi, imageFormat, image);