Hi,
Am 22.02.2016 um 18:35 schrieb Tilman Hausherr:
Am 22.02.2016 um 10:33 schrieb Peter Prusinowski:
Hello,
I have a method, that prints an image to a document. When calling this method
multiple times, I get a lot of debug messages :
0 [Finalizer] DEBUG org.apache.pdfbox.io.ScratchFileBuffer -
ScratchFileBuffer not closed!
I read something that the finalize is faster than the auto-close. How can that
be ? And how can I avoid it ? I am using 2.0 RC2/RC3, jai-imageio 1.1 and the
image file is 1 kb. Here is the code :
switch off the debug mode.
Nice idea, but doesn't solve the issue ;-)
I've found the issue and a fix, see PDFBOX-3253 [1] for further details.
@Peter: Thanks for the report!
BR
Andreas
[1] https://issues.apache.org/jira/browse/PDFBOX-3253
Tilman
public static void generate() throws IOException {
PDDocument doc = new PDDocument();
try {
PDPage page = new PDPage();
doc.addPage(page);
PDPageContentStream content = new PDPageContentStream(doc, page);
BufferedImage bi = ImageIO.read(new File("/tmp/test.png"));
PDImageXObject img = LosslessFactory.createFromImage(doc, bi);
content.drawImage(img, 0, 0);
content.close();
} finally {
if (doc != null) {
doc.save("/tmp/testPdf.pdf");
doc.close();
}
}
}
public static void main(String[] args) throws IOException {
BasicConfigurator.configure();
generate();
generate();
generate();
}
Thanks a lot,
Peter
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]