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 http://cocoon.apache.org/2.1/userdocs/concepts/modules-ref.html#ContextPathModule - 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,


Andy.
--
http://pseudoq.sourceforge.net/  Open source java Sudoku app

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to