如何在区域主体的底部放置一个块 [英] How to position a block at the bottom in the region-body

查看:30
本文介绍了如何在区域主体的底部放置一个块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在生成发票 PDF,我希望将 block 和增值税摘要 放在 region-body 的底部

I'm generating an invoice PDF and i want to have the block with the VAT Summary positioned at the bottom of the region-body

我(几乎)阅读了所有 ibex 和更一般的 xsl-fo 文档,我最接近的是学习如何在页面中绝对定位元素;

I read (almost) all the ibex and the more general xsl-fodocumentation and the closest i got was to learn how to absolutely position elements in the page;

但这不适合我的需要,因为我可能有许多可变大小的行,并且绝对定位的元素可能会与这些行重叠.

But that does not suit my needs because i may have many lines with variable size and the absolutely-positioned element may overlap the lines.

我正在使用 ibex xsl-fo 生成器.

I am using ibex xsl-fo generator.

一些示例代码

可以在此处

我在下面放了一些示例代码,这样人们就不必看到 1200 行长的原始 xsl-fo.

I put some sample code below so that one does not have to see the original xsl-fo that's 1200 lines long.

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
    <xsl:template match="/root">
        <fo:table>
            <fo:table-body>
                <fo:table-row>
                    <fo:table-cell>
                        <fo:block>
                            <xsl:value-of select="'I am up here'"/>
                        </fo:block>
                    </fo:table-cell>
                </fo:table-row>
                <!-- I'd like this table-row to be bottom aligned -->
                <fo:table-row>
                    <fo:table-cell>
                        <fo:block>
                            <xsl:value-of select="'I would like to be at the bottom of the region body'"/>
                        </fo:block>
                    </fo:table-cell>
                </fo:table-row>
            </fo:table-body>
        </fo:table>
    <xsl:template
</xsl:stylesheet>

推荐答案

在 XSL FO 中执行此操作的唯一方法是对最后一页使用页面模板并将该内容放在区域之后.没有结构可以产生橡皮筋"效果将内容推到底部,也不存在 float="bottom"(如果它不适合,无论如何都不会在你的情况下工作,它会浮动到底部第二页.你会使用我做过的另一个项目中的类似内容.

The only way to do this in XSL FO is to use page templates for the last page and put that content in the region-after. There is no structure that yields a "rubber-banding" effect to push the content to the bottom, nor does float="bottom" exist (which would not work in your case anyway if it dod not fit, it would float to the bottom of the second page. You would use something like this from another project I have done.

 <fo:layout-master-set>
    <!-- ============== simple-page-master ============ -->
    <fo:simple-page-master master-name="simple-page-master.only" page-height="792pt" page-width="612pt">
      <fo:region-body margin-top="4.15in" margin-right="0.25in" margin-bottom="2.6in" margin-left="0.25in" />
      <fo:region-before extent="792pt" region-name="region-before.only"/>
    </fo:simple-page-master>
    <!-- ============== simple-page-master ============ -->
    <fo:simple-page-master master-name="simple-page-master.first" page-height="792pt" page-width="612pt">
      <fo:region-body margin-top="4.15in" margin-right="0.25in" margin-bottom="2.6in" margin-left="0.25in" />
      <fo:region-before extent="792pt" region-name="region-before.first"/>
    </fo:simple-page-master>
    <!-- ============== simple-page-master ============ -->
    <fo:simple-page-master master-name="simple-page-master.rest" page-height="792pt" page-width="612pt">
      <fo:region-body margin-top="0.8in" margin-right="0.25in" margin-bottom="0.64in" margin-left="0.25in" />
      <fo:region-before extent="792pt" region-name="region-before.rest"/>
    </fo:simple-page-master>
    <!-- ============== simple-page-master ============ -->
    <fo:simple-page-master master-name="simple-page-master.last" page-height="792pt" page-width="612pt">
      <fo:region-body margin-top="0.8in" margin-right="0.25in" margin-bottom="2.58in" margin-left="0.25in" />
      <fo:region-before extent="792pt" region-name="region-before.last"/>
    </fo:simple-page-master>
    <!-- ============== page-sequence-master ============ -->
  <fo:page-sequence-master master-name="page-sequence-master">
       <fo:repeatable-page-master-alternatives maximum-repeats="no-limit">
        <fo:conditional-page-master-reference master-reference="simple-page-master.last" blank-or-not-blank="blank" />
         <fo:conditional-page-master-reference master-reference="simple-page-master.only" page-position="only" />
        <fo:conditional-page-master-reference master-reference="simple-page-master.first" page-position="first" />
        <fo:conditional-page-master-reference master-reference="simple-page-master.last" page-position="last" />
        <fo:conditional-page-master-reference master-reference="simple-page-master.rest" page-position="rest" />
       </fo:repeatable-page-master-alternatives> 
  </fo:page-sequence-master>
  </fo:layout-master-set>

这会为第一页、其余页、最后一页和特殊的页面(其中第一个是最后一个)创建模板.然后将页面底部的内容输出到适当的区域(region-before.only 和 region-before.last).

This creates templates for pages that are first, rest, last and a special one of only (where first is last). You then output that content you wish at the bottom of the page into the appropriate regions (both region-before.only and region-before.last).

唯一的警告/技巧是,如果您选择不同大小的页面布局来容纳底部所需的信息,那么您应该确保表格内部的最后几行保持在一起以拉出一些那些行到第二页.

The only caveat/trick is if you choose different sizes of page layout to accommodate the information you want at the bottom, then you should make sure the last few rows of the inside of your table are kept together to pull a few of those rows to the second page.

这篇关于如何在区域主体的底部放置一个块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆