On 2016-09-07 18:11 ( 0200), Tilman Hausherr <[email protected]> wrote:
> Am 07.09.2016 um 16:00 schrieb Markus Barbey:>
> > Hello there,>
> > >
> > I'm using PDFBox version 2.0.2 and I'm just struggling with the>
> > >
> > PDFRenderer#renderPageToGraphics (int, Graphics2D)>
> > >
> > implementation, which triggers the>
> > >
> > PageDrawer#drawImage (PDImage) throws IOException>
> > >
> > for image drawing. The PDImage instance is holding an image soft reference,
> > once the image has been resolved.>
> > >
> > When calling>
> > >
> > PDFRenderer#renderPageToGraphics (int, Graphics2D)>
> > >
> > multiple times for the same renderer instance, the>
> > >
> > PageDrawer#drawImage (PDImage) throws IOException>
> > >
> > gets always called with a freshly generated PDImage instance (which has not
> > yet a cached image to use). Therefore the image gets extracted from the PDF
> > stream anew, although it has already been cached in the previously used
> > PDImage instance.>
>
> The PDImageXObject should be cached thanks to the document wide cache >
> referenced in PDResources.>
>
> I haven't tested your observation yet; the only explanation for now >
> would be that your PDF was just created, i.e. not read from a file or a >
> stream. (Thus no COSObject references)>
>
> Tilman>
Ok...
found it... while examinating the cashing algorithm I found this comment/code
in PDResources#getXObject(COSName name):
// we can't cache PDImageXObject, because it holds page resources, see
PDFBOX-2370
if (cache != null && !(xobject instanceof PDImageXObject))
{
cache.put(indirect, xobject);
}
So the PDImageXObject is definitively not cached right now :-(
Markus
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]