pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Prusinowski <peter.pr...@gmx.de>
Subject ScratchFileBuffer not closed
Date Mon, 22 Feb 2016 09:33:33 GMT
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 :

     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: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Mime
View raw message