WeasyPrint icon indicating copy to clipboard operation
WeasyPrint copied to clipboard

Page Breaks are causing content to go missing

Open quirkles opened this issue 6 months ago • 1 comments

This is with weasyprint version 65.1, i dont know when exactly but it seems like it was introduced sometime after version 59.0

This is the relevant line in my template:

{{#if (isdefined coAppendix.budgetImpact)}}
  <div style="page-break-after: always;"></div>
  <div style="page-break-after: always;">

the pdf are attached:

output-v65-1.pdf

output-v50.0.pdf

As you can see the v65-1 file omits everything after the beginning of the appendix.

the input html is here (wont let me attach the html file itself):

<html lang="en"><head><meta charset="utf-8" /></head><body><div class="template-content">
    <div class="template-left">
        <div id="header_content">
            <div class="company-logo">
                <img src="https://firebasestorage.googleapis.com/v0/b/part3-dev.appspot.com/o/F1cPwuit54Yuy9MSMiMc%2FUB3v6pZQYG98wNHNIfyR%2Fdownload.png?alt=media&token=263cb553-8e20-4a9b-bae5-0b0d5180dce7"/>
            </div>
        </div>

    </div>
    <div class="template-right">
        <h1 class="bold">Change Order - CO-3.0</h1>
        <div class="project-info">
            <p class="info-date">
                Mon June 2, 2025
            </p>
            <p class="bold">Re: Quirk filesystem
            </p>
        </div>

        <div class="tiny-font statement"><div class="parse"><p>New CCDC 1234</p></div></div>


        <table class="mb-10 mt-15">
            <tbody>
            <tr>
                <td class="medium-col bold">Description:</td>
                <td><div class="parse"><p>asdasdasdas</p></div></td>
            </tr>
            </tbody>
        </table>

        <table class="mb-10 mt-15">
            <tbody>
            <tr>
                <td class="medium-col bold">Attach:</td>
                <td class="bold italic">
                    Star Building - Appliances - Part 1.pdf
                </td>
                <td class="col-pd italic">
                    06/02/2025
                </td>
            </tr>
            <tr>
                <td></td>
                <td class="bold italic">
                    LS4wisecrack nippy except.pdf
                </td>
                <td class="col-pd italic">
                    06/02/2025
                </td>
            </tr>
            </tbody>
        </table>

        <table class="mb-10 mt-15">
            <tbody>
            <tr>
                <td class="medium-col bold">Reason:</td>
                <td>Owner Request</td>
            </tr>
            </tbody>
        </table>




        <div class="quote avoid-page-break">

            <table>
                <tbody>
                <tr class="no-border no-border-top bold">
                    <td class="no-border extra-large-col extra-padding text-right">
                        The Contract Price is hereby adjusted in the amount of:
                    </td>
                    <td class="no-border medium-large-col extra-padding text-right">
                        $0.00
                    </td>
                </tr>
                <tr>
                    <td class="extra-large-col text-right">
                        Original Contract Amount:
                    </td>
                    <td class="medium-large-col text-right">
                        $0.00
                    </td>
                </tr>
                <tr>
                    <td class="extra-large-col text-right">
                        Previous Authorized Changes to Date:
                    </td>
                    <td class="medium-large-col text-right">
                        $0.00
                    </td>
                </tr>
                <tr>
                    <td class="extra-large-col text-right">
                        Authorized Changes to Date (including this order):
                    </td>
                    <td class="medium-large-col text-right">
                        $0.00
                    </td>
                </tr>
                <tr class="no-border bold">
                    <td class="no-border extra-large-col text-right">
                        Revised Contract Amount:
                    </td>
                    <td class="no-border medium-large-col text-right">
                        $0.00
                    </td>
                </tr>
                </tbody>
            </table>
            <p class="end days-added">
                This change adds <span class="bold">[3530]</span> days to the project schedule.
            </p>
            <p class="revised-date">
                Revised <span class="italic">Project end date</span>: <span class="bold underline">November 25, 2039</span>
            </p>
        </div>

        <div style="page-break-after: always;"></div>
        <div style="page-break-after: always;">
            <div><p class="bold">Budget impact from: CO-3.0: dfaasdasda</p></div>
        </div>

        <table class="approvers mt-15 avoid-page-break">
            <tbody>
            <tr>
                <td class="p0">Prepared by</td>
            </tr>
            <tr>
                <td class="p0 pb-20">Part3</td>
            </tr>
            <tr>
                <td class="p0">
                    .................................................................
                </td>
            </tr>
            <tr>
                <td class="p0">alex quirk test account</td>
            </tr>
            </tbody>
        </table>
        <div class="approvers mt-15">
        </div>

        <p class="bold mt-15 uppercase">Distribution:</p>
        <table class="distribution-list small-font">
            <tbody>
            <tr class="td-px-5">
                <td>Alice Tsui</td>
                <td></td>
                <td>[email protected]</td>
            </tr>
            <tr class="td-px-5">
                <td>Danny Smith</td>
                <td></td>
                <td>[email protected]</td>
            </tr>
            <tr class="td-px-5">
                <td>Alex Quirk update</td>
                <td class="breakWord">Part3</td>
                <td>[email protected]</td>
            </tr>
            <tr class="td-px-5">
                <td>Peter Smith</td>
                <td class="breakWord">Part3</td>
                <td>[email protected]</td>
            </tr>
            <tr class="td-px-5">
                <td>alex quirk test account</td>
                <td class="breakWord">Part3</td>
                <td>[email protected]</td>
            </tr>
            </tbody>
        </table>

        <div class="footnote approvers-note"><div class="parse"><p>vevfd</p></div></div>

    </div>
</div>
</body></html>

This is how im calling the weasyprint api:

        from weasyprint import HTML, CSS
         ...
        html = HTML(
            string=self.main_html
        )
        main_doc = html.render(
            stylesheets=self.stylesheets,
            font_config=self.font_config,
            presentational_hints=True,
        )
        pdf = NamedTemporaryFile(mode="w+b")
        main_doc.write_pdf(pdf.name)

quirkles avatar Jun 03 '25 13:06 quirkles

Hi!

Here’s what I get with your sample and WeasyPrint 65.1, I think that it’s what we want:

missing.pdf

Don’t you get the other 2 pages?

liZe avatar Jun 13 '25 14:06 liZe