问题
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.
回答1:
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>
回答2:
This builds upon Kevin's answer. The solution is to use a Formatted Object Processor that supports the feature. Apache FOP is feature anemic in some critical areas like floating an image (unless you are Gutenberg working with a printing press).
If you are looking for a free one, then try XEP (http://www.renderx.com/). It works as expected, and it has a free license for non-commercial projects.
For completeness, Sagehill lists a bunch of processors at http://www.sagehill.net/docbookxsl/FOprocessors.html. I tired three of the free ones, and they are all broken. The remaining free ones no longer exist (or their web pages are broken).
来源:https://stackoverflow.com/questions/19771669/block-image-right-and-flow-text-around-it