返回 关于XSL生成...... 登陆

关于XSL生成PDF分页的问题

巴扎黑 2017-01-11 10:53:40 571
<?xml version="1.0" encoding="GB2312"?>
<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="/">
            <xsl:processing-instruction name="cocoon-format">type="text/xslfo"</xsl:processing-instruction>
            
            <!--在此可以定义一些全局的风格信息,如字体等-->
            <fo:root  font-family="Verdana" font-size="10pt" xmlns:fo="http://www.w3.org/1999/XSL/Format">
              <!--版面定义//-->
              <fo:layout-master-set>
                <fo:simple-page-master margin-top="1cm" margin-bottom="0.5cm" margin-left="1.25cm" margin-right="1.25cm" page-width="21.0cm" page-height="40cm">
                      <!--页眉//-->
                      <fo:region-before extent="0.5cm"/>
                      <!--主体//-->
                      <fo:region-body margin-top="0cm" margin-bottom="1cm" margin-left="0cm" display-align="before"/>
                      <!--页脚//-->
                      <fo:region-after extent="3cm"/>
                </fo:simple-page-master>
              </fo:layout-master-set>
              <xsl:apply-templates SELECT="change_print" />
            </fo:root>
        </xsl:template>
        <!--主模板-->
        <xsl:template match="change_print">
            <fo:page-sequence>
                <!--定义页面样式引用,可以为首页、单数页、偶数页定义不同的页面风格-->
                   <fo:static-content flow-name="xsl-region-after">
<fo:block text-align="center">
<fo:table space-before.optimum="10pt" border-width="0pt" font-weight="normal" width="18.5cm" table-layout="fixed">
  <fo:table-column column-width="8.5cm"/>
  <fo:table-column column-width="5.0cm"/>
  <fo:table-column column-width="5.5cm"/>
  <fo:table-body>
<fo:table-row>
<fo:table-cell number-columns-spanned="3">
<fo:block>
<fo:external-graphic src="footer.JPG"/>
</fo:block>
</fo:table-cell>
</fo:table-row>                              
  </fo:table-body>
</fo:table>
</fo:block>
                   </fo:static-content>
<fo:flow flow-name="xsl-region-body" margin-bottom="3cm">
 <!--报表头-->
 <xsl:apply-templates SELECT="report_header"/>
 <!--报表体(若有多个部分内容,参照下面一行重复)-->
 <xsl:apply-templates SELECT="report_body"/>
</fo:flow>
            </fo:page-sequence>
        </xsl:template>
        <xsl:template match="report_header">
            <fo:table width="18.5cm" table-layout="fixed" border-collapse="separate" border-width="0pt">
                    <!-- 定义列(与实际列数严格一致) //-->
                    <fo:table-column column-width="18.5cm"/>
                    <fo:table-body>
<fo:table-row>
<fo:table-cell>
<fo:block>
<fo:external-graphic src="hellwndlogo.JPG" height="40pt"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row  font-size="10pt" border-width="0pt" border-style="solid" height="1cm">
<fo:table-cell border-color="black" border-width="0pt" border-style="solid">
<fo:block text-align="start">
<fo:inline white-space-collapse="false"> </fo:inline>
</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell>
<fo:block text-align="start" start-indent="0.2cm">
<xsl:value-of SELECT="file_ref" />
</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row  font-size="10pt" border-width="0pt" border-style="solid" height="1cm">
<fo:table-cell border-color="black" border-width="0pt" border-style="solid">
<fo:block text-align="start">
<fo:inline white-space-collapse="false"> </fo:inline>
</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell>
<fo:block text-align="start" start-indent="0.2cm">
<xsl:value-of SELECT="print_date" />
</fo:block>
</fo:table-cell>
</fo:table-row>
                    </fo:table-body>
                </fo:table>
        </xsl:template>
        <xsl:template match="report_body">
            <fo:table width="18.5cm" table-layout="fixed" space-before.optimum="1pt" border-collapse="separate" border-width="0.8pt" font-family="Verdana" font-size="10pt" font-weight="normal">
                    <!-- 定义列(与实际列数严格一致) //-->
                    <fo:table-column column-width="6.5cm"/>
                    <fo:table-column column-width="12cm"/>
                    <fo:table-body>
                        <fo:table-row>
                            <fo:table-cell border-width="0.6pt" number-columns-spanned="2">
<fo:block text-align="start">
<fo:table width="18.5cm" font-size="10pt" font-family="Verdana" table-layout="fixed" start-indent="0.2cm" space-before="1cm" space-after="1cm" border-collapse="separate" border-width="0pt" >
<fo:table-column column-width="20.45cm"/>
<fo:table-body>
<fo:table-row>
<fo:table-cell>
<fo:block text-align="start"><xsl:value-of SELECT="applicant_name" /></fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell>
<fo:block text-align="start"><xsl:value-of SELECT="rela_address" /></fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell>
<fo:block text-align="start"><xsl:value-of SELECT="rela_address_2" /></fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell>
<fo:block text-align="start"><xsl:value-of SELECT="rela_address_3" /></fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell>
<fo:block text-align="start"><xsl:value-of SELECT="rela_address_4" /></fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell>
<fo:block text-align="start">
<xsl:value-of SELECT="rela_zip" />
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
                                </fo:block>
                            </fo:table-cell>
                        </fo:table-row>
                        <fo:table-row>
                            <fo:table-cell border-width="0.6pt" border-bottom="none" border-top="none" border-right="none">
<fo:block text-align="start" start-indent="0.2cm" space-before="0.1cm" space-after="0.1cm">
<fo:inline white-space-collapse="false">Dear Policyholder</fo:inline>
</fo:block>
                            </fo:table-cell>
                        </fo:table-row>
<fo:table-row  font-size="10pt" border-width="0pt" border-style="solid" height="0.2cm">
<fo:table-cell border-color="black" border-width="0pt" border-style="solid">
<fo:block text-align="start">
<fo:inline white-space-collapse="false"> </fo:inline>
</fo:block>
</fo:table-cell>
</fo:table-row>
                        <fo:table-row font-weight="bold">
                            <fo:table-cell border-width="0.6pt" border-bottom="none" border-top="none" border-right="none" number-columns-spanned="2">
<fo:block text-align="start" start-indent="0.2cm" space-before="0.1cm" space-after="0.1cm">
ENDORSEMENT FOR POLICY NUMBER:   <xsl:value-of SELECT="policy_code" />
</fo:block>
                            </fo:table-cell>
                        </fo:table-row>
                        
<fo:table-row font-weight="bold">
<fo:table-cell border-width="0.6pt" border-bottom="none" border-right="none" number-columns-spanned="2">
<fo:block text-align="start" start-indent="0.2cm" space-before="0.1cm">
POLICY PLAN:<xsl:value-of SELECT="notice_code" />
</fo:block>
</fo:table-cell>                         
</fo:table-row>
                        <fo:table-row font-weight="bold">
<fo:table-cell border-width="0.6pt" border-top="none" border-right="none" number-columns-spanned="2">
<fo:block text-align="start" start-indent="0.2cm" space-before="0.1cm" space-after="0.1cm">
EFFECTIVE DATE:<xsl:value-of SELECT="validate_time" />
</fo:block>
</fo:table-cell>
                        </fo:table-row>
<fo:table-row  font-size="10pt" border-width="0pt" border-style="solid" height="0.5cm">
<fo:table-cell border-color="black" border-width="0pt" border-style="solid" number-columns-spanned="2">
<fo:block text-align="start">
<fo:inline white-space-collapse="false"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row  font-size="10pt" border-width="0pt" border-style="solid" height="0.5cm">
<fo:table-cell border-color="black" border-width="0pt" border-style="solid" number-columns-spanned="2">
<fo:block text-align="start" start-indent="0.2cm">
<fo:inline white-space-collapse="false" text-align="justify">We refer to your request and would like to inform you that the above-mentioned policy is terminated under the policy's Freelook provision.</fo:inline>
</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row  font-size="10pt" border-width="0pt" border-style="solid" height="0.5cm">
<fo:table-cell border-color="black" border-width="0pt" border-style="solid" number-columns-spanned="2">
<fo:block text-align="start">
<fo:inline white-space-collapse="false"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row  font-size="10pt" border-width="0pt" border-style="solid" height="0.5cm">
<fo:table-cell border-color="black" border-width="0pt" border-style="solid" number-columns-spanned="2">
<fo:block text-align="start" start-indent="0.2cm">
<fo:inline white-space-collapse="false" text-align="justify">If you have any queries, please feel free to contact our Customer Service Officers at 6788 1122, or email us at csquery@income.com.sg. We will be most happy to assist you.</fo:inline>
</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row  font-size="10pt" border-width="0pt" border-style="solid" height="0.5cm">
<fo:table-cell border-color="black" border-width="0pt" border-style="solid" number-columns-spanned="2">
<fo:block text-align="start">
<fo:inline white-space-collapse="false"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row  font-size="10pt" border-width="0pt" border-style="solid" height="0.5cm">
<fo:table-cell border-color="black" border-width="0pt" border-style="solid" number-columns-spanned="2">
<fo:block text-align="start" start-indent="0.2cm">
<fo:inline white-space-collapse="false" text-align="justify">Thank you and we hope to serve you again soon.</fo:inline>
</fo:block>
</fo:table-cell>
</fo:table-row>
                    </fo:table-body>
            </fo:table>
        <fo:table width="18.5cm" table-layout="fixed" space-before.optimum="11pt" border-collapse="separate" border-width="0pt"  font-family="Verdana" font-size="10pt" height="6cm">
                    <fo:table-column column-width="5.5cm"/>
                    <fo:table-column column-width="6cm"/>
                    <fo:table-column column-width="2cm"/>
                    <fo:table-column column-width="5cm"/>
                    <fo:table-body height="5cm">
<fo:table-row font-family="Verdana" font-size="10pt" border-width="0pt" height="0.5cm">
<fo:table-cell border-color="black" border-width="0pt" number-columns-spanned="3">
<fo:block text-align="start">
<fo:inline white-space-collapse="false"> </fo:inline>
</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row  font-size="10pt" border-width="0pt" border-style="solid" height="0.5cm">
<fo:table-cell border-color="black" border-width="0pt" border-style="solid" number-columns-spanned="2">
<fo:block text-align="start" start-indent="0.2cm">
<fo:inline white-space-collapse="false">Yours sincerely </fo:inline>
</fo:block>
</fo:table-cell>
</fo:table-row>
                        <fo:table-row>
 <fo:table-cell>
<fo:block text-align="start" start-indent="0.2cm">
<fo:external-graphic src="abc/good.jpg" height="50pt"/>
</fo:block>
</fo:table-cell>
                        </fo:table-row>
<fo:table-row  font-size="10pt" border-width="0pt" height="0.5cm">
<fo:table-cell border-width="0pt" number-columns-spanned="2">
<fo:block text-align="start" start-indent="0.2cm">
<fo:inline white-space-collapse="false">
AAAAA
BBBBB
CCCCC
</fo:inline>
</fo:block>
</fo:table-cell>
</fo:table-row>
                    </fo:table-body>
                </fo:table>
        </xsl:template>
</xsl:stylesheet>

最新手记推荐

• 用composer安装thinkphp框架的步骤 • 省市区接口说明 • 用thinkphp,后台新增栏目 • 管理员添加编辑删除 • 管理员添加编辑删除

全部回复(0)我要回复

暂无评论~
  • 取消 回复 发送
  • PHP中文网