On 27 May 2009, at 17:49, botunge wrote:
Hi
The reason for this "madness" is that i've made a java function
which is
able to calculate tab stops using the FOP event handlers FontInfo
class
(((org.apache.fop.fo.FOTreeBuilder)
fop.getDefaultHandler()).getEventHandler()). Using the fontInfo
class one
can get access to the fontmetrics of the font used to render a given
PDF
document, thereby calculating the length of a word before a tabstop.
My goal
is to create som fo:block and fo:leader elements with the text where
tabs
stop has been replaced by fo:leader elements.
If i just return the String "<fo:block>some text</fo:block>" the
output is
escape.
Not sure what's going wrong in your scenario, but this is indicative
of the FOTreeBuilder's MainFOHandler receiving a characters() event,
like
handler.characters({'<','f','o',':','b','l','o'...,'c','k','>'}, 0, 30);
What you actually need is to send it events like:
handler.startElement(FO_URI, "block", "fo:block", attrs);
handler.characters({'s','o','m','e',' ','t','e','x','t'}, 0, 9);
handler.endElement(FO_URI, "block", "fo:block");
IIC, you might be able to use FOP's fop.util.DOM2SAX[*] class to
generate SAX events from the DOM nodes you create. Pass in the
FOTreeBuilder as the target ContentHandler, and use the
writeDocument() method to insert the subtree into the result document.
Note that you will have to create a DOM Document, rather than a Node
or Element to get this to work.
[*]
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/util/DOM2SAX.java?revision=746664
HTH!
Andreas
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscr...@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-h...@xmlgraphics.apache.org