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 Phillip B Oldham <ph...@theactivitypeople.co.uk> on 2009/03/25 11:29:22 UTC

Using binary image data in an embedded environment

I'm using apache fop in an embedded environment; a stand-alone 
application receives an object with two attributes - the first is an FO 
string, the second is a list of image objects which themselves contain a 
filename and the binary data for that file.

I can generate the FO using the string, but I'm unable to find any 
documentation on how to load the binary files into fop and link to them 
in the FO to have them render in-place. At the moment I'm using the 
"data:" url scheme and "fo:instream-foreign-object", but these aren't 
optimal for my needs.

Can anyone provide an example of what I need to do, or point me in the 
right direction for a tutorial/reference/documentation?

Thanks.

Re: Using binary image data in an embedded environment

Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
The solution with the RFC 2397 data URLs is one possibility as you've
already found. Another would be to write your own URIResolver
implementation that you can set on the FOUserAgent. In your FO you'd
simply put the filenames after a custom URI scheme (ex. "my:" or "img:")
on which your URIResolver would react by returning a StreamSource
instance that has an InputStream that accesses the binary data.

Example:
filename: image1.jpg
--> URI: img:image1.jpg

There's a test case in FOP test suite that demonstrates this. The code
can be simplified in your case.
http://svn.eu.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/URIResolutionTestCase.java?view=markup
http://svn.eu.apache.org/viewvc/xmlgraphics/fop/trunk/test/xml/uri-resolution1.fo?view=markup

HTH

On 25.03.2009 12:29:22 Phillip B Oldham wrote:
> I'm using apache fop in an embedded environment; a stand-alone 
> application receives an object with two attributes - the first is an FO 
> string, the second is a list of image objects which themselves contain a 
> filename and the binary data for that file.
> 
> I can generate the FO using the string, but I'm unable to find any 
> documentation on how to load the binary files into fop and link to them 
> in the FO to have them render in-place. At the moment I'm using the 
> "data:" url scheme and "fo:instream-foreign-object", but these aren't 
> optimal for my needs.
> 
> Can anyone provide an example of what I need to do, or point me in the 
> right direction for a tutorial/reference/documentation?
> 
> Thanks.




Jeremias Maerki


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