Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.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
Xml 如何使用xsl fo页脚和页眉生成pdf?_Xml_Xslt_Pdf_Footer_Xsl Fo - Fatal编程技术网

Xml 如何使用xsl fo页脚和页眉生成pdf?

Xml 如何使用xsl fo页脚和页眉生成pdf?,xml,xslt,pdf,footer,xsl-fo,Xml,Xslt,Pdf,Footer,Xsl Fo,我正在尝试生成pdf,但我不知道如何在每个页面中添加页眉和页脚。我使用的是xsl fo名称空间,这里是xsl代码的根 <xsl:template match="ROOT"> <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"> <fo:layout-master-set> <fo:simple-page-mast

我正在尝试生成pdf,但我不知道如何在每个页面中添加页眉和页脚。我使用的是xsl fo名称空间,这里是xsl代码的根

  <xsl:template match="ROOT">
        <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
              <fo:layout-master-set>
                    <fo:simple-page-master master-name="simpleA4"
                          page-height="450mm" page-width="350mm" margin-top="20mm"
                          margin-bottom="20mm" margin-left="20mm" margin-right="20mm">
                          <fo:region-body border="solid thick black" />
                    </fo:simple-page-master>
                    <fo:page-sequence-master master-name="SequenceMaster1">
                          <fo:repeatable-page-master-reference
                                maximum-repeats="3" master-reference="simpleA4" />
                    </fo:page-sequence-master>
              </fo:layout-master-set>
              <xsl:apply-templates />
        </fo:root>
  </xsl:template>

和我的页面模板:

  <xsl:template match="PAGE">
        <fo:page-sequence master-reference="SequenceMaster1"
              text-align="center">
              <fo:flow flow-name="xsl-region-body">
                    <fo:block font-family="Arial" text-align="left"
                          language="tr">
                          <!-- ======================================Common Bigger table========================================================================================= -->
                          <fo:table width="100%" border-before-width="thin"
                                border-top-width="thick">
                                <fo:table-column column-width="310mm" />
                                <fo:table-body break-after="page" border-width="1mm" border-style="solid" height="410mm">
                                      <fo:table-row>
                                            <fo:table-cell padding-left="2mm" height="410mm">
                                                  <xsl:apply-templates />
                                            </fo:table-cell>
                                      </fo:table-row>
                                </fo:table-body>
                          </fo:table>
                    </fo:block>
              </fo:flow>
        </fo:page-sequence>
  </xsl:template>

我就是这样做的-在“fo:layout master set”中,我的页面母版看起来是这样的:

      <fo:simple-page-master master-name="section1-first-page" page-width="8.268055555555555in" page-height="11.693055555555556in" margin-top="35.45pt" margin-bottom="35.45pt" margin-right="70.9pt" margin-left="70.9pt">
         <fo:region-body margin-top="21.25pt" margin-bottom="21.25pt"></fo:region-body>
         <fo:region-before region-name="first-page-header" extent="11in"></fo:region-before>
         <fo:region-after region-name="first-page-footer" extent="11in" display-align="after"></fo:region-after>
      </fo:simple-page-master>

fo:页眉区域名称之前的区域,而fo:页脚区域名称之后的区域

要添加内容,必须在“fo:flow”之前添加到“fo:page sequence”:

      <fo:static-content flow-name="first-page-header">
         <fo:block><fo:inline>HEADER TEXT</fo:inline></fo:block>
      </fo:static-content>
      <fo:static-content flow-name="first-page-footer">
         <fo:block><fo:inline>FOOTER TEXT</fo:inline></fo:block>
      </fo:static-content>

标题文本
页脚文本
显然,您可以将流名称更改为您想要的任何名称。这只是我代码中的一个示例