Kozea / WeasyPrint

The awesome document factory
https://weasyprint.org
BSD 3-Clause "New" or "Revised" License
7.21k stars 683 forks source link

Repeating <thead> and <tfoot> on every page with border-collapse: collapse #76

Closed SimonSapin closed 11 years ago

SimonSapin commented 11 years ago

Table border collapsing is annoying to do when header and footer row groups are repeated on every page. We should still do it. Later.

https://github.com/Kozea/WeasyPrint/blob/v0.19/weasyprint/formatting_structure/build.py#L507

    # XXX For now table headers and footers in the collapsing border model
    # are not repeated on every page.
mzu commented 10 years ago

Hi. Is there a way to turn off repeating <thead> and <tfoot> on every page?

SimonSapin commented 10 years ago

@mzu Repeating on every page is the only real difference <thead> and <tfoot> have with <tbody>, so you could just use <tbody>. Or, if you’d rather not change the markup for some reason, use the following CSS:

thead, tfoot { display: table-row-group }
mzu commented 10 years ago

@SimonSapin Great, thanks.

NailaAkbar00 commented 6 years ago

@mzu how did you show/ repeat headers and footers on each page??

mmulqueen commented 1 year ago

Sorry to necropost, I've had to remind myself of this multiple times, so to answer @NailaAkbar00 's question:

If you want table headers to repeat, it's sufficient to wrap the rows you wish to repeat in a thead tag.

<!-- Contents of thead is repeated on every page by Weasyprint.  -->

<!-- Default CSS includes: -->
<!-- thead { display: table-header-group; } -->

<table>
    <thead>
        <tr>
            <th>Country</th><th>Capital</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>France</td><td>Paris</td>
        </tr>
        <tr>
            <td>Germany</td><td>Berlin</td>
        </tr>
        <tr>
            <td>Italy</td><td>Rome</td>
        </tr>
    </tbody>
</table>

<!-- If for some reason, you don't want thead to be repeated on every page, you can use the following CSS rule: -->
<!-- thead { display: table-row-group; } -->

This shows how Weasyprint behaves: http://test.weasyprint.org/suite-css21/chapter17/section2/test35/