xmlgraphics-fop-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From TvT <tvtre...@nepatec.de>
Subject Re: Referring to a image file in a JAR file
Date Wed, 21 Jul 2010 15:16:03 GMT
Hi,

we needed exactly that and implemented our own "ResourceResolver" for that.
You can register it like the following:

//Register a custom resolver
foUserAgent.setURIResolver(new ClasspathResourceResolver());

//The clas has to implement the URIResolver
public class ClasspathResourceResolver implements URIResolver {

//you overwrite the resolve method
public InputStream resolve(String uri){

//Resolves the path to a resource in the classpath (since that jar
should be in the classpath
this.getClass().getResourceAsStream(uri);

Regards,
ToM


2010/7/21 Bernard Giannetti <thebernmeister@hotmail.com>:
> Hi,
>
> I am trying to refer to a graphic file within a JAR file.  The JAR file
> contains the application which is being executed along with the
> aforementioned graphic file.
>
> The application is launched via JNLP - so not sure if that effects what I am
> trying to do.
>
> If the JAR file is myapp.jar and the graphic is say image.svg then the tag
>
> <fo:external-graphic src="file://myapp.jar!/image.svg" content-width=8"
> content-height="8"> results in the error
>
> Error with opening URL 'file://myapp.jar!/image.svg'
>
> I have tried different variations on the src attribute, say file:/// and
> then also url('/image.svg') but with similar errors.
>
> Is it possible to reference an image file within the same JAR as the
> application?
>
>
> Thanks in advance,
>
> Bernard.

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Mime
View raw message