Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

colspan bug at write_pdf #1250

Closed
SilverGeri opened this issue Nov 17, 2020 · 2 comments
Closed

colspan bug at write_pdf #1250

SilverGeri opened this issue Nov 17, 2020 · 2 comments
Labels
bug Existing features not working as expected
Milestone

Comments

@SilverGeri
Copy link

I want to generate a table from a list of products then add the sum price to the end of the table. I need a signature section at the end of each page
when there are too many products and the table is split between more pages, colspan is applied to the last row of each page instead of only the last one where it is correct. I checked the generated html, it is fine but when I save it to pdf, the bug appears

         th, td {
            border: 1px solid black;
            padding: 1mm;
        }

        table {
            border-collapse: collapse;
            width: 100%;
            font-size: 12px;
            page-break-inside: auto;
        }

        tr {
            page-break-inside: avoid;
            page-break-after: auto;
        }
        thead {
            display: table-header-group;
        }

        tbody {
            border: 1px solid black;
        }

        tfoot {
            display: table-footer-group;
        }

        .footer {
            padding-top: 10mm;
            padding-bottom: 6mm;
            border-style: none;
        }

        .footer-wrapper {
            width: 46mm;
            margin-left: auto;
            text-align: center;
        }
<div style="page-break-before: always">
    <table>
        <thead>
            <tr>
                <th>id.</th>
                <th>productname</th>
                <th>price</th>
                <th>quantity</th>
                <th>sum</th>
            </tr>
        </thead>
        <tbody>
            {% for product in products.all %}
            <tr>
                <td>{{ forloop.counter }}</td>
                <td>{{ product.name }}</td>
                <td>{{ product.gross_price|floatformat:0 }}&nbsp;Ft</td>
                <td>{{ product.quantity }}&nbsp;{{ item.product.unit }}</td>
                <td>{{ product.total_price|floatformat:0 }}&nbsp;Ft</td>
            </tr>
            {% endfor %}
            <tr>
                <td colspan="4">Sum</td>
                <td>{{ products_total_price|floatformat:0 }}&nbsp;Ft</td>
            </tr>
        </tbody>
        <tfoot>
            <tr>
                <td class="footer" colspan="5">
                    <div class="footer-wrapper">
                        <span>
                            ........................................<br>
                            {{ name }}
                        </span>
                    </div>
                </td>
            </tr>
        </tfoot>
    </table>
</div>
@liZe liZe added the bug Existing features not working as expected label Nov 23, 2020
@liZe
Copy link
Member

liZe commented Nov 23, 2020

when there are too many products and the table is split between more pages, colspan is applied to the last row of each page instead of only the last one where it is correct.

You’re right! That’s a dirty bug…

@liZe liZe closed this as completed in f0231c8 Nov 23, 2020
@liZe liZe added this to the 52.2 milestone Nov 23, 2020
@liZe
Copy link
Member

liZe commented Nov 23, 2020

For each page, vertical lines were drawn on the last line as they were drawn on the last page. It only happened for tables with a footer.

All previous tests pass, another one has been added, just in case…

liZe added a commit that referenced this issue Nov 25, 2020
The previous logic used to find if a row is in the footer was broken. Code is
now cleaner, shorter, with an example in comments and a non-regression test.

Fix #1250.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Existing features not working as expected
Projects
None yet
Development

No branches or pull requests

2 participants