cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andy Stevens <>
Subject Re: Relative paths in fop-0.94
Date Thu, 07 Feb 2008 00:43:00 GMT
Carlos Martínez wrote:
> Hello,
> I'm using a fop-0.94 in my local cocoon site to create PDF. All work 
> properly but the path of the images always have to be absolute. I don't 
> know how to change this.

Unless things have changed from the earlier FOP version, you can't. 
Actually, that's not strictly true.  Cocoon's source resolver isn't 
passed through to FOP, so cocoon: protocol URLs won't work.  But fully 
qualified http: URLs should be okay too, which is okay so long as the 
hostname can be resolved by the box that's running Cocoon.  On an 
internal network that's probably okay, but introduce a DMZ, run the app 
server on a different box to the internet-facing web server and firewall 
it off from direct internet access, and you'll have all sorts of trouble 
getting it working ;-)

> > I'm using a serializer that i see here:
> <map:serializer name="fo2pdf" mime-type="application/pdf" 
> src="CocoonFOPSerializer">
>        <set-content-length>false</set-content-length>
>        <user-config>cocoon://fop-config.xml</user-config>
> </map:serializer>
> And i created the fop-config.xml file with all the fonts:

If you're using cocoon:// in the <user-config>, have you included a 
pipeline that matches that path (using e.g. file generator & xml 
serializer to return your config file)?  Otherwise I think you just need 
the relative path to the config file from the sitemap's location.

> <configuration>
>    <fonts>
>          <!-- A lot of uninsteresting fonts -->
>    </fonts>
> </configuration>
> I try to put some sentences in the fop-config.xml file before the tag 
> "fonts" that i see in some forums, but it doesn't work. Here are some 
> lines of this codes:
> <entry>
>         <key>baseDir</key>
>        <value>C:\mypath</value>
> </entry>

I never had any luck getting this to work either, so I came up with an 
alternative approach.  I too used cocoon: in the user-config setting, 
but instead of a static configuration file, I generate it dynamically in 
the matching pipeline.  With e.g. an XSL transformer and passing in an 
xsl:param with the real path to the fonts directory - see 
- the pipeline output contains the absolute paths that FOP expects in 
the configuration, but without having to hard code the path in the 
application so it doesn't matter where the war file gets expanded to 
when deployed in different environments.

And, since you mentioned images, those can work in much the same way. 
Assuming you've already got an XSL transformation generating the xslfo 
from your source file/data, just add a top level xsl:param for the image 
file path, and pass it in from the sitemap using the input module.  Then 
prepend the parameter to the image paths in the XSL generating the 
fo:external-graphic tags, to make them absolute.

That should do the trick for bitmaps; on the offchance it's charts 
you're including there is another option.  If you can produce/convert 
them as SVG, then just include the SVG with your other data (via map 
aggregation or the x/cinclude transformer) and have the XSL put them 
inside fo:instream-foreign-object elements at the appropriate points. 
No paths required.

Hope this helps,

--  Open source java Sudoku app

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message