Apache FOP 2.0:我可以在图像周围环绕文字吗?

Apache FOP 2.0: Can I wrap text around images?

这是关于 Block Image Right and Flow Text Around It? 的后续问题。正如那里的回答,Apache FOP 1.1 无法在图像周围环绕文字。

几个月前,V2.0 发布了。根据 compliance page 部分支持 浮动。

由于我是 XSLT/FOP 的新手(并且不知道如何解释那里报告的限制),我想知道在图片周围环绕文字是否一般适用于 2.0。 (如果有人可以提供使用 Apache FOP 2.0 生成的演示 pdf 就太好了)

fo:float 适用于 FOP 2.0,因为他们将其列为 FOP 2.0 的主要新功能之一。您将不得不对您的内容进行试验,看看这些限制是否会导致不需要的文本环绕您的图像。由于 FOP 2.0 不支持浮动的 clear 属性,如果在页面的同一水平区域内有太多浮动,则可能会有重叠的图像。

自 2002 年以来我一直在使用 Antenna House Formatter,因为它支持更多 功能比早期版本的 FOP。如果 FOP 2.0 中对浮动的部分支持不能满足您的需求,您可以付费购买具有完整浮动支持的更好的工具。

http://xmlgraphics.apache.org/fop/fo.html#floats

Floats (fo:float) are supported with some limitations:

  • the "clear" fo:float attribute is ignored; only the float attribute (left or right) is used

  • overlapping of floats in the Y is not handled (even in the case there would not be overlap in the X direction)

  • floats that extend beyond the body region are not properly handled and will overflow past the edge of the region

  • if a float extends to bottom of the body region and there are footnotes in the page the float may overlap with the footnote region

  • floats next to a table are not supported unless the start and end of the table happens in between the start and end of the float

如果您修改文件会更有用,但您可以修改带有图像的示例 fo 文件以查看 fo:float 的工作原理。我稍微修改了这个文件 "fop-2.0\examples\fo\basic\alignment.fo":

<fo:float float="left">
<fo:block>
<fo:instream-foreign-object vertical-align="top">
<svg:svg width="25" height="25">
  <svg:rect x="0" y="0" width="25" height="25" style="fill:none;stroke:#000000"/>
  <svg:line x1="12.5" y1="3" x2="12.5" y2="22" style="stroke:black;stroke-width:1.5"/>
  <svg:path d="M5 17l7.5 8l7.5 -8z" style="fill:black"/>
  <svg:path d="M5 8l7.5 -8l7.5 8z" style="fill:black"/>
</svg:svg>
</fo:instream-foreign-object>
</fo:block>
</fo:float>