XSLFO - 显示页眉和页脚

时间:2018-05-06 09:56:26

标签: xslt xsl-fo apache-fop

使用XSL FO将xml转换为PDF。我想以下面的格式显示标题内容

Header Contents

Line 1               Line 1.1
Line 2               Line 1.2
Line 2               Line 1.3

现在,我正在尝试以下代码行:

 <fo:block> Line 1 </fo:block> <fo:block>   Line 1.1 </fo:block>
 <fo:block> Line 2 </fo:block> <fo:block>   Line 1.2 </fo:block>
 <fo:block> Line 3 </fo:block> <fo:block>   Line 1.3 </fo:block>

2 个答案:

答案 0 :(得分:1)

它看起来像表格布局:

        <fo:table width="100%">
            <fo:table-body>
                <fo:table-row>
                    <fo:table-cell>
                        <fo:block> Line 1 </fo:block>
                    </fo:table-cell>
                    <fo:table-cell>
                        <fo:block text-align="right"> Line 1.1 </fo:block>
                    </fo:table-cell>
                </fo:table-row>
                <fo:table-row>
                    <fo:table-cell>
                        <fo:block> Line 2 </fo:block>
                    </fo:table-cell>
                    <fo:table-cell>
                        <fo:block text-align="right"> Line 1.2 </fo:block>
                    </fo:table-cell>
                </fo:table-row>
                <fo:table-row>
                    <fo:table-cell>
                        <fo:block> Line 3 </fo:block>
                    </fo:table-cell>
                    <fo:table-cell>
                        <fo:block text-align="right"> Line 1.3 </fo:block>
                    </fo:table-cell>
                </fo:table-row>
            </fo:table-body>
        </fo:table>

答案 1 :(得分:1)

如果你想找到&#34;第1行&#34;对齐到标题的左侧和&#34;第1.1行和第34行;对齐标题的右侧,不需要使用表格布局。下面的示例使用*--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) <ipython-input-1-1ff77c8b7a69> in <module>() 1 import tensorflow as tf 2 from __future__ import absolute_import, division, print_function ----> 3 tf.enable_eager_execution() AttributeError: 'module' object has no attribute 'enable_eager_execution'* 对象来完成此要求。

fo:leader

FOP格式化结果: FOP Formatting result