You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by James Green <ja...@gmail.com> on 2013/03/11 16:08:09 UTC

Warning when using PDFTextStripper

I have a unit test which features the following method:

    private void checkPage(final PDDocument rendered, final int pageNumber,
final List<String> expected, final List<String> unexpected) throws
IOException {
        PDFTextStripper stripper = new PDFTextStripper();
        stripper.setStartPage(pageNumber);
        stripper.setEndPage(pageNumber);
        System.out.println("checkPage is getting text");
        String content = stripper.getText(rendered);
        System.out.println("checkPage has text");
        for (String expect : expected) {
            Assert.assertTrue(content.contains(expect));
        }
        for (String unexpect : unexpected) {
            Assert.assertFalse(content.contains(unexpect));
        }
    }

Between "checkPage is getting text" and "checkPage is getting text" on the
console I get:

14:56:45,765  WARN org.apache.pdfbox.cos.COSDocument:530 finalize() -
Warning: You did not close a PDF Document

I realise that System.gc() might be happening at some other point but as
yet I have failed to spot any reason behind this warning. It is consistent
in appearing between these two messages under repeated execution.

PDFBox 1.7.1 is being used. Any ideas?

Thanks,

James