1
votes

Table footer is not showing if table extends to next page.

continue text should come at the end of that table in first page. similar to table header which is coming properly.Whenever the table is extended to next page the "cont" should appear at the end of first page.

Sample XML:

<NewDataSet>
    <DefaultView>
     <Department>2222</Department>
     <Title>Manish</Title>
   </DefaultView>
   <DefaultView>
     <Department>2223</Department>
     <Title>Santosh</Title>
   </DefaultView>
   <DefaultView>
     <Department>2224</Department>
     <Title>Naveen</Title>
   </DefaultView>
   <DefaultView>
     <Department>2225</Department>
     <Title>punith</Title>
   </DefaultView>
   <DefaultView>
     <Department>2226</Department>
     <Title>bharath</Title>
   </DefaultView>
   <DefaultView>
     <Department>2227</Department>
     <Title>vijay</Title>
   </DefaultView>
 </NewDataSet>

Sample XSL:

    <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                              xmlns:fo="http://www.w3.org/1999/XSL/Format"
                              xmlns:rx="http://www.renderx.com/XSL/Extensions"
                              xmlns:psmi="http://www.CraneSoftwrights.com/resources/psmi"
                              xmlns:exsl="http://exslt.org/common">
  <xsl:template match='NewDataSet'>
    <fo:root>
      <fo:layout-master-set>
        <fo:simple-page-master master-name="my-page">
          <fo:region-body margin="1in"/>
        </fo:simple-page-master>
      </fo:layout-master-set>
      <fo:page-sequence master-reference="my-page">
        <fo:flow flow-name="xsl-region-body">
        <fo:table>  
              <fo:table-column column-width="25mm"/>
              <fo:table-column column-width="25mm"/>
              <fo:table-header  keep-together="always">
                        <fo:block text-align="center" font-style="italic" margin="5pt" keep-together="always">
                            <xsl:text>Table</xsl:text>
                        </fo:block>
                </fo:table-header>
        </fo:table>
          <fo:table-and-caption>  
            <fo:table rx:table-omit-initial-header="true">  
              <fo:table-column column-width="25mm"/>
              <fo:table-column column-width="25mm"/>
              <fo:table-header  keep-together="always">
                        <fo:block text-align="center" font-style="italic" margin="5pt" keep-together="always">
                            <xsl:text>Table (Cont.)</xsl:text>
                        </fo:block>
                </fo:table-header>

              <fo:table-header >
                <fo:table-row>
                  <fo:table-cell border-color="black" border-style="solid" width = "85pt" border-width="0.4pt" padding="3pt" align="left">
                    <fo:block font-weight="bold">Dept</fo:block>
                  </fo:table-cell >
                  <fo:table-cell border-color="black" border-style="solid" width = "85pt" border-width="0.4pt" padding="3pt" align="left">
                    <fo:block font-weight="bold">Title</fo:block>
                  </fo:table-cell>
                </fo:table-row>
              </fo:table-header>
              <xsl:for-each select="*">
                <fo:table-body>
                  <fo:table-row>
                    <fo:table-cell border-color="black" border-style="solid" width = "85pt" border-width="0.4pt" padding="3pt" align="left">
                      <fo:block>
                        <xsl:value-of select="Department"/>
                      </fo:block>
                    </fo:table-cell>
                    <fo:table-cell border-color="black" border-style="solid" width = "85pt" border-width="0.4pt" padding="3pt" align="left">
                      <fo:block>
                        <xsl:value-of select="Title"/>
                      </fo:block>
                    </fo:table-cell>
                  </fo:table-row>
                </fo:table-body>
              </xsl:for-each>
            </fo:table>
          </fo:table-and-caption>
        </fo:flow>
      </fo:page-sequence>
    </fo:root>
  </xsl:template>
</xsl:stylesheet>

Sample output: enter image description here

1
There is no fo:table-footer in your sample XSLT. (Also, if you put the fo:table-body outside the xsl:for-each, you'll generate only one fo:table-body, and you really only need one.)Tony Graham
NOTE: Unlike omitting the start header for a table, there is no equivalent to omitting the last footer. If you idea is to have a footer that says "Table continued on next page" you can use markers and pull into the footer area and clear the marker at the end of the table.Kevin Brown
Hi Kevin,Can you please provide some example to clear marker in table footer, so that it will be helpful for us to do the same. Thanks in advance.Logeshwaran
Please look at the answer, I added comments for you. You can see right after the table it is as simple as setting the marker as an empty element. This would make it "blank". As such, it would pull nothing to the footer. You would repeat that surrounding your tables ... set the marker to the continued text, format the table, set the marker to nothing.Kevin Brown
For below data also footer is coming at end of the page. footer should come only if table content extends to next page.If table content is not extended to next page then only table should come not footer content on that page. <NewDataSet> <DefaultView> <Department>2222</Department> <Title>Manish</Title> </DefaultView> <DefaultView> <Department>2223</Department> <Title>Santosh</Title> </DefaultView> </NewDataSet>Logeshwaran

1 Answers

2
votes

Combining this with the other answer about table headers (Table header is not getting repeated, if table content extended to next page in PDF using XSLT), here is a complete example showing both the table header and the footer being pulled as a marker into footer area when the table carries over.

    <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:fo="http://www.w3.org/1999/XSL/Format"
        xmlns:rx="http://www.renderx.com/XSL/Extensions"
        xmlns:psmi="http://www.CraneSoftwrights.com/resources/psmi"
        xmlns:exsl="http://exslt.org/common">


        <xsl:template match='NewDataSet'>
            <fo:root>
                <fo:layout-master-set>
                    <fo:simple-page-master master-name="my-page">
                        <fo:region-body margin="1in"/>
                        <fo:region-after extent="1in"/>
                    </fo:simple-page-master>
                </fo:layout-master-set>
                <fo:page-sequence master-reference="my-page">
                    <fo:static-content flow-name="xsl-region-after">
                       <!-- This retrieves the marker into the footer -->
                        <fo:block>
                           <fo:retrieve-marker retrieve-class-name="table" retrieve-position="last-ending-within-page"/>
                        </fo:block>
                    </fo:static-content>
                    <fo:flow flow-name="xsl-region-body">
                       <!-- This sets the marker content for the footer -->
                        <fo:block>
                            <fo:marker marker-class-name="table">
                                Table continued on next page
                            </fo:marker>
                        </fo:block>
                            <fo:table-and-caption>
                                <fo:table rx:table-omit-initial-header="true">  
                                    <fo:table-column column-width="25mm"/>
                                    <fo:table-column column-width="25mm"/>
                                    <fo:table-header  keep-together="always">
                                        <fo:table-row>
                                            <fo:table-cell number-columns-spanned="2"><fo:block text-align="center" font-style="italic" margin="5pt" keep-together="always">
                                                <xsl:text>Table (Cont.)</xsl:text>
                                            </fo:block>
                                        </fo:table-cell>
                                        </fo:table-row>
                                        <fo:table-row>
                                        <fo:table-cell border-color="black" border-style="solid" width = "85pt" border-width="0.4pt" padding="3pt" >
                                            <fo:block font-weight="bold">Department</fo:block>
                                        </fo:table-cell >
                                        <fo:table-cell border-color="black" border-style="solid" width = "85pt" border-width="0.4pt" padding="3pt" >
                                            <fo:block font-weight="bold">Title</fo:block>
                                        </fo:table-cell>
                                        </fo:table-row>
                                    </fo:table-header>
                                    <fo:table-body>
                                        <fo:table-row>
                                            <fo:table-cell border-color="black" border-style="solid" width = "85pt" border-width="0.4pt" padding="3pt" >
                                                <fo:block font-weight="bold">Depaartment</fo:block>
                                            </fo:table-cell >
                                            <fo:table-cell border-color="black" border-style="solid" width = "85pt" border-width="0.4pt" padding="3pt" >
                                                <fo:block font-weight="bold">Title</fo:block>
                                            </fo:table-cell>
                                        </fo:table-row>
                                        <xsl:apply-templates/>
                                    </fo:table-body>
                                </fo:table>
                            </fo:table-and-caption>
                        <!-- IMPORTANT -- This clears the marker so it does not appear on pages where the table ends -->
                        <fo:block keep-with-previous.within-page="always">
                            <fo:marker marker-class-name="table"/>
                        </fo:block>
                    </fo:flow>
                </fo:page-sequence>
            </fo:root>
        </xsl:template>
        <xsl:template match="DefaultView">
            <fo:table-row>
                <fo:table-cell border-color="black" border-style="solid" width = "85pt" border-width="0.4pt" padding="3pt" >
                    <fo:block>
                        <xsl:value-of select="Department"/>
                    </fo:block>
                </fo:table-cell>
                <fo:table-cell border-color="black" border-style="solid" width = "85pt" border-width="0.4pt" padding="3pt" >
                    <fo:block>
                        <xsl:value-of select="Title"/>
                    </fo:block>
                </fo:table-cell>
            </fo:table-row>
        </xsl:template>
    </xsl:stylesheet>

The result is:

enter image description here

And if you had many pages is:

enter image description here

And if you have less than one page is:

enter image description here