6

我们的客户要求提供带圆角的 PDF 格式的表格。我只有 Apache FOP 处理器可供我使用,它不支持圆角属性。它也不支持浮动,因此无法将圆形图像向左和向右浮动。

你对如何做到这一点有什么建议吗?

4

3 回答 3

5

您可以将表格创建为可缩放矢量图形 (SVG) 对象,并将其作为外部图像包含在 XSL-FO 文档中。SVG 支持圆角,FOP 支持 SVG。

我相信您也可以创建一个圆角矩形 SVG 并将其用作内容的背景,然后将表格放在它的前面。我想我做过一次,但我似乎无法找到代码......

于 2009-11-08T04:50:17.270 回答
1

只要它是固定宽度并且不期望像css那样动态地“浮动”宽度,我已经做到了(通过使用垂直的“滑动门”技术,如果你还记得老式的css):

获取一个圆角背景图像,只要您希望出现在页面上就拥有它(请注意,如果您希望内容进入多个页面,那么这不会很好,呵呵)。我在页眉/页脚和开始新页面(在正文区域)的东西上使用它,我知道它不会超过 1 页。

然后我决定我是否需要一个固定的高度......如果是这样,你可以使用没有花哨的背景图像......

如果高度会有所不同,那么我只需将图像的顶部用于一部分,将图像的底部用于另一部分。像这样的东西:

<fo:block-container>
  <fo:block-container background-image="url(images/rounded_corner_image.png)" 
  background-repeat="no-repeat"
  background-position-horizontal="15px" 
  background-position-vertical="top"              
  background-color="white"
  >
  <!-- 
  So it used the top of the image for as long as the block-container exists heightwise.
  I may have had some whitespace in my image and need to move image into place so think I used background-position-horizontal since i had 15px of whitespace i wanted to cut off 
  Also you may set a height above if definatley know you don't need it to 'auto-expand', just make sure you have content that can't overflow if setting height (like a table with Name: Address: fields)
  -->
    <fo:block margin="70px 70px 0px 70px">
      Need to add some margins before starting content since dont want to text to touch the top and sides of of the rounded corner/borders plus add whitespace for content.
    </fo:block>
  </fo:block-container>

  <fo:block-container background-image="url(images/rounded_corner_image.png)" 
  background-repeat="no-repeat"
  background-position-horizontal="15px"
  background-position-vertical="bottom"
  padding="0px 0px 20px 0px"
  background-color="white"
  >
    <fo:block margin="0px 70px 70px 70px">
      Need to add some margins before starting content since dont want to text to touch bottom and sides of of the rounded corner/borders.
    </fo:block>
  </fo:block-container>

</fo:block-container>

我认为有多种方法可以解决。就像我在底部有内容一样,所以我只使用底部知道我肯定会有至少 70px 的内容来显示我的圆角的底部渐变......你可以决定将所有内容放在第一个块容器并为第二个块容器提供 70px 的固定高度以仅显示底部背景图像(我认为即使底部容器中没有内容[忘记 xsl-fo 规则],这也是可能的)。使用 FOP 主干,效果很好。

编辑:我应该注意我使用最新的 FOP 1.0(也尝试过使用 prev 版本),并且效果很好。我还使用了一个与内容一样高的图形,因为我有边框......如果你只需要顶部和底部的图形(以及背景颜色来填充主体,那么就不需要完整的 'as-tall-as - 可能的图像)。

于 2010-07-29T17:37:41.843 回答
1

圆角支持:

于 2015-11-13T14:35:25.470 回答