Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xslt 无法生成静态第二页-fop_Xslt_Apache Fop - Fatal编程技术网

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

Xslt 无法生成静态第二页-fop,xslt,apache-fop,Xslt,Apache Fop,我正在尝试使用FOP生成PDF 我的要求- 第1页-标题和内容 第2页-术语的静态页面 第3页-从第1页溢出 但是,当第1页没有溢出时,就不会生成第2页。我希望生成第二页,即使第1页没有溢出。第二页我有不同的布局 下面是带有布局集的fo文件- <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:fox="http://xmlgraphics.apache.org/fop/extensions" xmlns

我正在尝试使用FOP生成PDF

我的要求-

第1页-标题和内容

第2页-术语的静态页面

第3页-从第1页溢出

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

下面是带有布局集的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=“偶数”确保第二个页面始终存在。但是,我如何确保当出现溢出(从第1页到第3页)时,不应该有第4页(这将是空白的),我可以为您提供两个不完美的解决方案。上面那个是第一个。第二个是添加一个fo:block,其属性为break after=“偶数页”。两种解决方案都有您已经注意到的相同问题。我不认为您可以解决这个问题,因为xsl不支持页面,并且您不能定义最少的页面。静态页面有多静态?可以是PDF或图像吗?您可以读取区域树并对其进行格式化,然后对页面重新排序静态页面(第2页)具有静态文本。第一页的内容应该溢出到第三页。第二个页面始终具有静态内容。是的,它是PDF格式的。