You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by Bernard Giannetti <th...@hotmail.com> on 2010/07/21 16:48:14 UTC

Referring to a image file in a JAR file

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.

 		 	   		  
_________________________________________________________________
If It Exists, You'll Find it on SEEK. Australia's #1 job site
http://clk.atdmt.com/NMN/go/157639755/direct/01/

Re: Referring to a image file in a JAR file

Posted by TvT <tv...@nepatec.de>.
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 <th...@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