Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Page break inside table XSL-FO

I have an XSL-FO stylesheet for a table.

<fo:page-sequence master-reference="defaultPage">
  <fo:flow flow-name="xsl-region-body">
    <fo:table table-layout="fixed" width="100%">
      <fo:table-column column-width="9pt"/>
      <fo:table-column column-width="30pt"/>
      <fo:table-column column-width="150pt"/>
      <fo:table-header>
        <fo:table-row>
          <fo:table-cell>
            <fo:block><xsl:text>Column 1</xsl:text></fo:block>
          </fo:table-cell>
          <fo:table-cell>
            <fo:block><xsl:text>Column 2</xsl:text></fo:block>
          </fo:table-cell>
          <fo:table-cell>
            <fo:block><xsl:text>Column 3</xsl:text></fo:block>
          </fo:table-cell>
        </fo:table-row>
      </fo:table-header>
      <fo:table-body>
        <fo:table-row>
          <xsl:apply-templates select="rbrOcjena"/>
          <xsl:apply-templates select="sifPred"/>
          <xsl:apply-templates select="nazPred"/>
        </fo:table-row>
      </fo:table-body>
    </fo:table>
  </fo:flow>
</fo:page-sequence>

The table can have many rows, so I'd like to break it on new page when it comes to the end of current, when generating PDF. Also, I would like to repeat table header on new page, if that's possible. What attributes should I put in the table tag to make it so?

Thanks!

like image 850
skruzic Avatar asked Jan 10 '23 23:01

skruzic


1 Answers

The table can have many rows, so I'd like to break it on new page when it comes to the end of current

Without seeing your XSL-FO code, it is difficult to answer this. Please show it. But generally, this is done with keeps and breaks. For example:

<fo:table-row keep-together.within-page="always">

I would like to repeat table header on new page, if that's possible. What attributes should I put in the table tag to make it so?

Instructing an XSL-FO processor to repeat a number of rows at the top of every page is not done via an attribute to fo:table. Instead, the rows that are to be repeated are put inside fo:table-header:

<fo:table-header>
   <fo:table-row>
      <fo:table-cell>
         <!--Block and text content-->
      </fo:table-cell>
   </fo:table-row>
</fo:table-header>

Then, the default behaviour of the processor should be to repeat the header rows after a page break. That's because the omit-header-at-break attribute of fo:table is set to "false" by default.

The most obvious reason for this is that it is immediately clear which rows belong to the header and should thus be repeated. If this was just a reference in an attribute of fo:table it would be harder to identify multiple rows as the header. You will find the relevant part of the XSL specification here.

like image 115
Mathias Müller Avatar answered Jan 26 '23 03:01

Mathias Müller