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

DOMPDF to enable automatic page breaks when encountering large content in <td> wrapper #1046

Open
rajanish93 opened this issue May 6, 2024 · 3 comments

Comments

@rajanish93
Copy link

<style> body { font-family: verdana, sans-serif; }
    table {
        margin-bottom: 2em;
    }

    thead {
        background-color: #eeeeee;
    }

    tbody {
        background-color: #ffffee;
    }

    th,
    td {
        padding: 3pt;
    }

    table.separate {
        border-collapse: separate;
        border-spacing: 5pt;
        border: 3pt solid #33d;
    }

    table.separate td {
        border: 2pt solid #33d;
    }

    table.collapse {
        border-collapse: collapse;
        border: 1pt solid black;
    }

    table.collapse td {
        width: 612px;
        height: 792px;
        overflow: hidden;
        font-family: Arial, Helvetica;
        position: relative;
        color: #545554;
        page-break-after: always;
    }
</style>

To insert a page break in pdf, the html code must have an element with the style page-break-before: always or page-break-after: always. Before or after that specific element, a page break will be inserted into the generated pdf document. The element can be anything (image, table, table row, div, text, etc).

            <p>To insert a page break in pdf, the html code must have an element with the style
                page-break-before: always or page-break-after: always. Before or after that specific
                element, a page break will be inserted into the generated pdf document. The element can
                be anything (image, table, table row, div, text, etc).</p>

            <p>To insert a page break in pdf, the html code must have an element with the style
                page-break-before: always or page-break-after: always. Before or after that specific
                element, a page break will be inserted into the generated pdf document. The element can
                be anything (image, table, table row, div, text, etc).</p>

            <p>To insert a page break in pdf, the html code must have an element with the style
                page-break-before: always or page-break-after: always. Before or after that specific
                element, a page break will be inserted into the generated pdf document. The element can
                be anything (image, table, table row, div, text, etc).</p>

            <p>To insert a page break in pdf, the html code must have an element with the style
                page-break-before: always or page-break-after: always. Before or after that specific
                element, a page break will be inserted into the generated pdf document. The element can
                be anything (image, table, table row, div, text, etc).</p>


            <p>To insert a page break in pdf, the html code must have an element with the style
                page-break-before: always or page-break-after: always. Before or after that specific
                element, a page break will be inserted into the generated pdf document. The element can
                be anything (image, table, table row, div, text, etc).</p>

            <p>To insert a page break in pdf, the html code must have an element with the style
                page-break-before: always or page-break-after: always. Before or after that specific
                element, a page break will be inserted into the generated pdf document. The element can
                be anything (image, table, table row, div, text, etc).</p>


            <p>To insert a page break in pdf, the html code must have an element with the style
                page-break-before: always or page-break-after: always. Before or after that specific
                element, a page break will be inserted into the generated pdf document. The element can
                be anything (image, table, table row, div, text, etc).</p>


            <p>To insert a page break in pdf, the html code must have an element with the style
                page-break-before: always or page-break-after: always. Before or after that specific
                element, a page break will be inserted into the generated pdf document. The element can
                be anything (image, table, table row, div, text, etc).</p>


            <p>To insert a page break in pdf, the html code must have an element with the style
                page-break-before: always or page-break-after: always. Before or after that specific
                element, a page break will be inserted into the generated pdf document. The element can
                be anything (image, table, table row, div, text, etc).</p>


            <p>To insert a page break in pdf, the html code must have an element with the style
                page-break-before: always or page-break-after: always. Before or after that specific
                element, a page break will be inserted into the generated pdf document. The element can
                be anything (image, table, table row, div, text, etc).</p>


            <p>To insert a page break in pdf, the html code must have an element with the style
                page-break-before: always or page-break-after: always. Before or after that specific
                element, a page break will be inserted into the generated pdf document. The element can
                be anything (image, table, table row, div, text, etc).</p>


            <p>To insert a page break in pdf, the html code must have an element with the style
                page-break-before: always or page-break-after: always. Before or after that specific
                element, a page break will be inserted into the generated pdf document. The element can
                be anything (image, table, table row, div, text, etc).</p>

        </td>
    </tr>

</table>
When I put large content in
wrapper pdf unable to show all content and created blank page before starting content.
@rajanish93
Copy link
Author

This exactly issue occurred on below URL:

https://eclecticgeek.com/dompdf/debug.php?identifier=f333a1b5cedfbec3ceeff081b8fbf857

@parallels999
Copy link

**This is just a Dompdf wrapper!**
I understand that this package is just a Laravel wrapper for https://github.com/dompdf/dompdf
Any issues with PDF rendering, CSS that is not applied correctly, aligning/fonts/characters etc that are not directly related to this package, should be reported there. When having doubts, please try to reproduce the issue with just dompdf. If it's also present there, do not open an issue here please.

This is just a Dompdf wrapper!
I understand that this package is just a Laravel wrapper for https://github.com/dompdf/dompdf
Any issues with PDF rendering, CSS that is not applied correctly, aligning/fonts/characters/images/html etc that are not directly related to this package, should be reported there. When having doubts, please try to reproduce the issue with just dompdf. If it's also present there, do not open an issue here please.

@ronaldaraujo
Copy link

"Dompdf does not support making a new page using a table cells/rows between pages. Meaning if the text on your table is too long, it will move on the next page. Also all data inside the table will move also on the next page."

So, in my case I need to change table for div.

before

<table cellpadding="2px" cellspacing="0px" class="mrg-top-18" style="width: 100%">
   <thead>
      <tr class="columns">
         <th width="100%">Avaliação Médica</th>
      </tr>
   </thead>
   <tbody>
      <tr>
         <td width="100%">{!! nl2br(e($patient->exam_2)) !!}</td>
      </tr>
   </tbody>
</table>

after

<div style="margin-top: 18px; width: 100%;">
    <div style="font-weight: bold; text-align: left; border-bottom: 1px solid #000; padding-bottom: 5px;">
        Avaliação Médica
    </div>
    <div style="padding-top: 10px; text-align: left;">
        {!! nl2br(e($patient->exam_2)) !!}
    </div>
</div>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants