Search code examples
xmlimagexsltapache-fopdocbook

Block Image Right and Flow Text Around It?


I'm working with DockBook 4.5 and Apache FOP 1.1 on Ubuntu 13.04. The Docbook translation are provided by Ubuntu and FOP was downloaded directly from Apache.

Would someone please tell me how to insert an image on the right of a paragraph, where the paragraph has text, too? Bonus points if scaling works (think: thumbnail). For example:

xxx xxx xxx xxx  +---------------+
xxxxxx xx xxx    |               |
xxxx xxxxx xxxxx |     Image     |
xxx xxxx xxx     |               |
xxx xxx xxxx xxx +---------------+
xxxxx xx xxx xxxx xxxxxx xx xx xxx
xx xxxxx xxx xxxxxxx  xxx xxxx xx
...

According to Wrap Text Around Image and Figure, I should be able to use floatstyle on a figure. But its not working for me.

I'm obviously doing something wrong, like pressing ENTER with the wrong finger. I won't bore readers with all the failed attempts using suggestions from the web over the past three or four hours. But they include figure, informalfigure, mediaobject, inlinemediaobject, imageobject, scale, floatstyle, and countless other tags in untold combinations.


Solution

  • you need to use a formatter tnat supports fo:float.

    http://xmlgraphics.apache.org/fop/compliance.html

    For an example, it would be like this:

    <fo:float float="right">
    <fo:block text-align="center"
              border="1pt solid gray"
              font="bold italic 9pt Helvetica">
      <fo:block>
        <fo:external-graphic src="url('smile.gif')"/>
      </fo:block>
      <fo:block>
        Fig. 1: A Smiling Face
      </fo:block>
    </fo:block>
    </fo:float>