I'm using FOP 0.95, and have happily been running with a custom URIResolver 
class to load and embed SVG images into my PDF output.

Earlier today I changed the build process so that all the jar files that were 
required by FOP to be in the classpath were un-jar'd and included in my main 
.jar file. Since then, I've not been able to load a single image. Here is my 
resolver class:

    private class ImgURIResolver implements URIResolver {
        private static final String uriprefix = "img:";
        private URIResolver defaultResolver;
        protected ImgURIResolver() {}
        public ImgURIResolver(URIResolver defaultResolver) {
            this.defaultResolver = defaultResolver;
        }
        public Source resolve(String href, String base) throws 
TransformerException {
            if (href.startsWith(PREFIX)){
                    String name = href.substring(uriprefix.length());
                    try {
                        for( int i = 0; i < PDFRenderer.images.size(); i++ ) {
                                Image img = PDFRenderer.images.get(i);
                                if( img.filename.equals(name) ) {
                                        return new StreamSource(new 
ByteArrayInputStream(img.filedata));
                                    }
                            }
                    } catch (Exception e) {
                        throw new TransformerException(e.getMessage());
                    }
                }
            return defaultResolver.resolve(href, base);
        }
    }

The images are loaded into memory in another class, and I can confirm that the 
img.filedata is there.

The errors I see are as follows:
242405 [pool-1-thread-2] ERROR org.apache.fop.fo.FONode - Image not available: 
No ImagePreloader found for img:myimage.svg
242408 [pool-1-thread-2] ERROR org.apache.fop.render - Image not found: 
img:myimage.svg

Inline SVGs work as expected.

I'm at a loss as to what has changed... I've not removed any files, or changed 
anything other than the build.xml file to unjar dependencies & bundle 
everything into one file.

Any ideas on how I can investigate/resolve this?
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to