pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Hewson <j...@jahewson.com>
Subject Re: PDFRenderer
Date Wed, 04 Mar 2015 17:38:25 GMT

> On 4 Mar 2015, at 07:35, Eric Douglas <edouglas@blockhouse.com> wrote:
> 
> I'm using org.apache.pdfbox.rendering.PDFRenderer renderPageToGraphics
> method in a GUI component.
> This PDFRenderer requires a document in the constructor.  This render
> method requires the document to be open.  PDDocument.load creates and opens
> the document object.  How much overhead is in this method?

PDDocument.load has significant overhead, opening a PDF is an expensive operation.

> I either need to call the load method every time I call the render method,
> or I need to make sure it loads once and call the close method when the
> component gets destroyed?

You want to make sure that you only have one PDDocument open for a given PDF.

> If I don't call the close method I get this message in my logs.
> org.apache.pdfbox.cos.COSDocument finalize
> WARNING: Warning: You did not close a PDF Document

Yep, PDDocument implements Closeable, so you need to call close() on it.

— John
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Mime
View raw message