barryvdh laravel dompdf rendering just two pages
Asked Answered
F

2

8

I am using barryvdh laravel dompdf for rendering pdf from html view in laravel 5.7. It was working fine but when the view exceeds to more than 2 pages it cuts the page and does not print the third page. However if i copy all the page data and paste it somewhere else the who content is pasted which means the content is there somehow but not showing.

This issue was also mentioned in the github repository but was not answered by anyone.

I am using Laravel 5.7

This is code :

    $pdf = PDF::loadview('emails.send-email.case-email-pdf', compact('pdf_data'));


    $file_name = 'case-email-'.$data['case_id'].str_random(10).time().'.pdf';

    Storage::put($config['folder'].'/'.$file_name,$pdf->output());
Ferocity answered 18/4, 2019 at 10:54 Comment(1)
Not sure if this is a solution for you, but you can try putting some parts in divs and try page-break-inside:avoid; on these divs. Playing around with the page breaks helped me multiple times when being stuck in domPDF with weird behaviors.Ess
F
1

The solution was to NOT USE table tag. Use divs instead.

Ferocity answered 22/4, 2019 at 12:8 Comment(1)
Nice solution. But I figure out something else. I just wrote some inappropriate syntax inside table tag accidentally, and it worked for me. ` <table> <tr> <td> My Data </td> <td> My Data </td> Some dummy data with display: none; </tr> </table> ` And it worked.Squirm
H
0

I don't love this answer, but the problem in my case was a long table contained within a second table:

<table>
    <tr>
        <td>
            <h1>Heading</h1>
        </td>
    </tr>
    <tr>
        <td> 
            <table>
                [lots and lots of data]
            </table>
        </td>
    </tr>
</table>

If I moved the long table outside of the container table, everything worked fine:

<table>
    <tr>
        <td>
            <h1>Heading</h1>
        </td>
    </tr>
</table>
<table>
    [lots and lots of data]
</table>

(I know making a "heading" table for an h1 is overkill; in my case the heading table contained a bunch of formatted-ish data in rows and columns, hence the need for a table.)

Helbonna answered 17/9, 2023 at 15:7 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.