2009-10-16 88 views
6

我们客户的要求是使用圆角的PDF格式的表格。我只有Apache FOP处理器,并且它不支持圆角属性。它也不支持浮动,所以浮动圆形图像左右无法完成。XSL-FO中的圆角

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

回答

5

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

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

0

只要它是固定的宽度,不要期望的东西'动态'像css动态宽度智慧,我已经做到了这一点(由使用垂直'滑动门'技术,如果你还记得老派的CSS):

获得一个圆角的背景图像,只要你期望在页面上就可以了(注意,如果你期望的东西上多个页面,那么这将不会工作得那么好)。我用它在页眉/页脚和开始一个新页面的东西(在身体区域),我知道不会超过1页。

于是我决定,如果我需要一个固定的高度......如果是这样,你可以只使用一个背景图片,没有fancyness ...

如果高度将发生变化,那么我只是用图像的顶部一部分和另一部分图像的底部。这样的事情:

<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> 

Theres各种方式去它我认为。就像我有内容在底部,所以我只是使用底部知道我肯定会有至少70px的内容来显示我的圆角的底部渐变....你可能会决定把所有的内容放在第一个块容器,并给第二个块容器固定的高度为70px,只显示底部背景图像(我认为这是可能的,即使没有内容存在于底部容器[忘记xsl-fo规则])。使用FOP中继并很好地工作。

编辑:我应该注意我使用最新的FOP 1.0(也尝试过prev版本),它运作良好。此外,我使用的图形与内容一样高,因为我具有边框......如果您只需要顶部和底部图形(并使用背景色填充主体,则不需要完整的'as-tall-as - 可能'图像)。