xslt - 无法生成静态第二页 - fop

标签 xslt apache-fop

我正在尝试使用 FOP 生成 PDF。

我的要求——

第 1 页 - 标题和内容

第 2 页 - 条款的静态页面

第 3 页 - 从第 1 页溢出

但是,当第 1 页没有溢出时,不会生成第 2 页。即使第 1 页没有溢出,我也希望生成第二页。而且,我对第 2 页有不同的布局。

下面是带有布局设置的 fo 文件-

<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:fox="http://xmlgraphics.apache.org/fop/extensions"
         xmlns:th="http://www.thymeleaf.org">
    <fo:layout-master-set>
        <!-- layout for the first page -->
        <fo:simple-page-master master-name="first"
                               th:attr="page-width=${dimensions.width} + 'in',page-height=${dimensions.height} + 'in',margin-right=${rightMargin} + 'in',margin-left=${leftMargin} + 'in'"
                               margin-top="0pt" margin-bottom="1in">
            <fo:region-body region-name="xsl-region-body" margin-top="3.3in" margin-bottom="0.375in"/>
            <fo:region-before region-name="stmt-header" margin-top="0.5in"/>
            <fo:region-after region-name="stmt-footer"/>
        </fo:simple-page-master>

        <!-- layout for the other pages -->
        <fo:simple-page-master master-name="rest"
                               th:attr="page-width=${dimensions.width} + 'in',page-height=${dimensions.height} + 'in',margin-right=${rightMargin} + 'in',margin-left=${leftMargin} + 'in'"
                               margin-top="0pt" margin-bottom="1in">
            <fo:region-body margin-bottom="0.375in" margin-top="1in"/>
            <fo:region-before region-name="stmt-header-1" margin-top="0.5in"/>
            <fo:region-after region-name="stmt-footer"/>
        </fo:simple-page-master>

        <!-- layout for the other pages -->
        <fo:simple-page-master master-name="terms"
                               th:attr="page-width=${dimensions.width} + 'in',page-height=${dimensions.height} + 'in',margin-right=${rightMargin} + 'in',margin-left=${leftMargin} + 'in'"
                               margin-top="0pt" margin-bottom="1in">
            <fo:region-body margin-top="10in" margin-bottom="0.1in"/>
            <fo:region-before region-name="stmt-terms" margin-top="0.5in"/>
            <fo:region-after region-name="stmt-footer-1"/>
        </fo:simple-page-master>

        <fo:page-sequence-master master-name="Statement">
            <!--<fo:repeatable-page-master-alternatives>-->
                <!--<fo:conditional-page-master-reference master-reference="first" page-position="first"/>-->
                <!--<fo:conditional-page-master-reference master-reference="terms" page-position="only"/>-->
                <!--<fo:conditional-page-master-reference master-reference="rest" page-position="rest"/>-->
            <!--</fo:repeatable-page-master-alternatives>-->
            <fo:single-page-master-reference master-reference="first"/>
            <fo:single-page-master-reference master-reference="terms"/>
            <fo:repeatable-page-master-alternatives>
                <fo:conditional-page-master-reference master-reference="rest" page-position="rest"/>
            </fo:repeatable-page-master-alternatives>
        </fo:page-sequence-master>

    </fo:layout-master-set>
    <!-- end: defines page layout -->

    <!-- actual layout -->
    <fo:page-sequence master-reference="Statement" id="stmt">

        <fo:static-content flow-name="stmt-header">
            <th:block th:include="header-logo :: header-logo"/>
        </fo:static-content>

        <fo:static-content flow-name="stmt-header-1">
            <th:block th:include="header-logo :: header-logo-1"/>
        </fo:static-content>

        <fo:static-content th:with="footer_margin_left=1.7" flow-name="stmt-footer">
            <th:block th:include="footer"/>
        </fo:static-content>

        <fo:static-content th:with="footer_margin_left=0" flow-name="stmt-footer-1">
            <th:block th:include="footer"/>
        </fo:static-content>

        <fo:static-content flow-name="stmt-terms">
            <th:block th:include="stmt_terms :: stmt-terms"/>
        </fo:static-content>

        <fo:flow flow-name="xsl-region-body">
            <th:block th:include="${templateLayoutContent} :: stmt-body"/>
        </fo:flow>



    </fo:page-sequence>

</fo:root>

有人可以帮我吗?

最佳答案

我想你正在寻找这个:force-page-count="even"
这可确保您的页面序列始终具有偶数页。事实上,那时必须有第二页。如果页面没有内容,可以通过blank-or-not-blank指定使用的page-master和静态内容。条件页面母版的属性。

关于xslt - 无法生成静态第二页 - fop,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47429701/

相关文章:

xml - XSLT - 使用正则表达式复制部分属性值

xsl-fo - FOP 中的字体系列

java - 如何指定xml文档与ant中的资源集合进行转换?

java - 是否可以从 Android 上的 Xalan 调用 Java 扩展函数?

xml - 需要帮助 - 使用 XSLT 根据条件添加/替换/删除 XML 中的节点

php - 在 xslt 转换中保留节点

java - Apache FOP - 如何找到哪些数据将打印在哪个页面上

java - 支持来自 Apache FOP PDF 生成的外部 CSS 文件

php - 在 FOP 生成的 PDF 文件中包含 PDF 文件

xml - 使用 ApacheFOP 在 Java 中从 XML 生成 PDF