question about empty images embedded into FOP generated PDF

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

question about empty images embedded into FOP generated PDF

Carl Buxbaum

Hello,

In some of our reports we have entities that attempt to embed an empty image.  That is, we blindly try to attach an image when the reference to the image is empty.  This results in a tortuously slow “ls” of the file store.  

This is what we normally try to do:

<fo:block text-align="center">
<xsl:variable name="image2">
<xsl:value-of select="attachment/@location" />
</xsl:variable>
<fo:external-graphic src="{$image2}"
content-width="350px" content-height="350px" />
</fo:block>

We have an awkward workaround of always testing for a non-empty @location, or we instruct the user to to modify file permissions to wx instead of rwx.

I was wondering if it would make sense in the FOP code, in ExternalGraphic.java bind method:

 /** {@inheritDoc} */

    public void bind(PropertyList pList) throws FOPException {

        super.bind(pList);

        src = pList.get(PR_SRC).getString();


        //Additional processing: obtain the image's intrinsic size and baseline information

        url = URISpecification.getURL(src);

        FOUserAgent userAgent = getUserAgent();

        ImageManager manager = userAgent.getImageManager();

        ImageInfo info = null;

        try {

            info = manager.getImageInfo(url, userAgent.getImageSessionContext());

        } catch (ImageException e) {

            ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get(

                    getUserAgent().getEventBroadcaster());

            eventProducer.imageError(this, url, e, getLocator());

        } catch (FileNotFoundException fnfe) {

            ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get(

                    getUserAgent().getEventBroadcaster());

            eventProducer.imageNotFound(this, url, fnfe, getLocator());

        } catch (IOException ioe) {

            ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get(

                    getUserAgent().getEventBroadcaster());

            eventProducer.imageIOError(this, url, ioe, getLocator());

        }

        if (info != null) {

            this.intrinsicWidth = info.getSize().getWidthMpt();

            this.intrinsicHeight = info.getSize().getHeightMpt();

            int baseline = info.getSize().getBaselinePositionFromBottom();

            if (baseline != 0) {

                this.intrinsicAlignmentAdjust

                    = FixedLength.getInstance(-baseline);

            }

        }

    }


to check for a URL that ends with the file separator or URL forward slash, and just return a FileNotFoundException in that case?  Is there any use case that this would disrupt?  We have users who have millions of images in their file store, and every time we run into one of these calls it consumes needless seconds or minutes of processing time until they are told that there is no Image Processor for <blank>.  


Thanks,


Carl

 

BambooRose Email Disclaimer
DISCLAIMER:
E-mails and attachments from Bamboo Rose, LLC are confidential.
If you are not the intended recipient, please notify the sender immediately by replying to the e-mail, and then delete it without making copies or using it in any way.
No representation is made that this email or any attachments are free of viruses. Virus scanning is recommended and is the responsibility of the recipient.