在XSLT

时间:2015-12-14 09:23:20

标签: xml xslt xsl-fo apache-fop

我们需要使用FOP生成PDF。在这里,我面临着在XSLT中动态更改块容器高度的问题。我试过设置最小值&最大高度。如果是这种情况,如果我们提供的内容较少,则高度将仅根据该值反映PDF格式。

有没有解决方案?

1 个答案:

答案 0 :(得分:2)

也许您需要发布更多问题。除非您指定高度(使用Apache FOP时),否则块容器的大小将与内容一致:

示例FO:

        <fo:flow flow-name="xsl-region-body">
        <fo:block-container position="absolute" top="10pt" left="10pt" width="2.5in" border="1pt solid silver" background-color="#f4f4f4">
            <fo:block margin="5pt">Kasd elitr voluptua autem voluptua amet possim id soluta laoreet tincidunt elitr sed quod consetetur velit eos diam. Magna gubergren rebum diam accusam gubergren nisl ipsum lorem ullamcorper gubergren assum sea suscipit amet eos et lorem. Amet kasd sit diam ipsum dolor no odio. Esse stet ad sanctus dolor hendrerit ut nonumy ipsum dolor dolor takimata lorem sit facer. Mazim tempor ut est. Dignissim erat consequat dolore diam eirmod ut. Sit nonumy stet. Sit kasd invidunt sadipscing lorem elitr lorem ut. At diam sed eirmod id ea lorem lorem consetetur rebum takimata labore exerci dolor soluta. Assum tempor invidunt adipiscing gubergren ut ad nonumy ea eu consequat lobortis diam eirmod amet et volutpat minim gubergren.</fo:block>
        </fo:block-container>
        <fo:block-container position="absolute" top="80pt" left="40pt" width="5in" border="1pt solid silver" background-color="#f4b4c4">
            <fo:block margin="5pt">Kasd elitr voluptua autem voluptua amet possim id soluta laoreet tincidunt elitr sed quod consetetur velit eos diam. Magna gubergren rebum diam accusam gubergren nisl ipsum lorem ullamcorper gubergren assum sea suscipit amet eos et lorem. Amet kasd sit diam ipsum dolor no odio. Esse stet ad sanctus dolor hendrerit ut nonumy ipsum dolor dolor takimata lorem sit facer. Mazim tempor ut est. Dignissim erat consequat dolore diam eirmod ut. Sit nonumy stet. Sit kasd invidunt sadipscing lorem elitr lorem ut. At diam sed eirmod id ea lorem lorem consetetur rebum takimata labore exerci dolor soluta. Assum tempor invidunt adipiscing gubergren ut ad nonumy ea eu consequat lobortis diam eirmod amet et volutpat minim gubergren.</fo:block>
        </fo:block-container>
        <fo:block-container position="absolute" top="140pt" left="100pt" width="3in" border="1pt solid silver" background-color="#b4b4f4">
            <fo:block margin="5pt">Kasd elitr voluptua autem voluptua amet possim id soluta laoreet tincidunt elitr sed quod consetetur velit eos diam. Magna gubergren rebum diam accusam gubergren nisl ipsum lorem ullamcorper gubergren assum sea suscipit amet eos et lorem. Amet kasd sit diam ipsum dolor no odio. Esse stet ad sanctus dolor hendrerit ut nonumy ipsum dolor dolor takimata lorem sit facer. Mazim tempor ut est. Dignissim erat consequat dolore diam eirmod ut. Sit nonumy stet. Sit kasd invidunt sadipscing lorem elitr lorem ut. At diam sed eirmod id ea lorem lorem consetetur rebum takimata labore exerci dolor soluta. Assum tempor invidunt adipiscing gubergren ut ad nonumy ea eu consequat lobortis diam eirmod amet et volutpat minim gubergren.</fo:block>
        </fo:block-container>
    </fo:flow>

输出显示三者中每一个的高度是内容的高度:

enter image description here