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 Gustavo Lopez <Gu...@tetratech-ffx.com> on 2003/02/03 21:03:50 UTC

How to include an external graphic using a relative path

Using FOP, I succesfully wrote a servlet to generate PDF's from in-memory DOM object's containing XSL-FO markup.

I able to embed graphics files by specifying a physical path as in: 

<fo:external-graphic src="url(/project/img/image.gif)"/>

However, since this is a web application, I need to be able to specify a relative path for the image file.

Thanks for you help,



/**     
 Gustavo C. Lopez                
 Tetra Tech, Inc.                
 10306 Eaton Place, Suite 340    
 Fairfax, VA  22030              
 @Voice: (703) 385-6000 x335      
 @Fax: (703) 385-6007             
 @Email: gustavo.lopez@tetratech-ffx.com
 @Url: http://www.ttwater.com
*/



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


Re: How to include an external graphic using a relative path

Posted by Johan Ã…brandt <jo...@profitsoftware.com>.
> You can define baseDir property (see faq howto) as 
> getServletContext().getRealPath("/project/img") 


snip...


Just a reminder that getRealPath( ... ) is allowed to return null if the 
application is deployed for example in a war file, according to the 
servlet spec. This advice is hence likely to work, but it is not portable.


__________________________________________________________________________

This message and its attachments have been found clean from known viruses 
with three different antivirus programs.
__________________________________________________________________________

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


Re: How to include an external graphic using a relative path

Posted by Oleg Tkachenko <ol...@multiconn.com>.
Gustavo Lopez wrote:
> Using FOP, I succesfully wrote a servlet to generate PDF's from in-memory DOM object's containing XSL-FO markup.
> 
> I able to embed graphics files by specifying a physical path as in: 
> 
> <fo:external-graphic src="url(/project/img/image.gif)"/>
> 
> However, since this is a web application, I need to be able to specify a relative path for the image file.

You can define baseDir property (see faq howto) as 
getServletContext().getRealPath("/project/img") and then use relative 
pathes in fo:external-graphic.

-- 
Oleg Tkachenko
eXperanto team
Multiconn Technologies, Israel


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