pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Markus Barbey" <Bar...@gmx.de>
Subject Re: PDFRender does not use cached image versions in renderPageToGraphics(int, Graphics2D)
Date Thu, 08 Sep 2016 06:33:52 GMT


On 2016-09-07 18:11 ( 0200), Tilman Hausherr <T...@t-online.de> 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: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Mime
View raw message