On 27 May 2009, at 14:32, Subrata Hazra wrote:

Can anybody help me with step-by-step guide for writing own FOP extension. I want to write some extension where fop will output an image parsing fo
document like this

<fo:block>
<ns:img xmlns="some URI" width="100" height="100">
<ns:bar height="10">bar1</bar>
<ns:bar height="10">bar2</bar>
</ns:img>

Internally I want to generate BufferedImage from Graphics2D then forward the
same to FOP.

Apart from what Manuel and Tim already suggested, what you could do, is implement it as a custom FO extension. SVG can be taken as an example, although SVG is only implemented to work if it is child to a fo:instream-foreign-object. It does, however, offer a fairly good picture of all the work that needs to be done to process foreign XML (not in the default FO namespace). The Barcode4J extension may also be of interest here.[*]

On the FOP side, be sure to take a look at org.apache.fop.fo.flow.InstreamForeignObject and its superclass org.apache.fop.fo.flow.AbstractGraphics.[**]
Chances are you can reuse a lot of the existing code.
I'm guessing that, with a bit of imagination, it should be possible to implement your extension as a subclass of AbstractGraphics (so you can reuse the same LayoutManager; otherwise, you would need to provide an extension LM together with the extension node, and add a mapping for that...)


[*] http://barcode4j.sourceforge.net/
[**] 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/InstreamForeignObject.java?revision=679326
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/AbstractGraphics.java?revision=679326

HTH!

Andreas

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

Reply via email to