How to divide a table into 2 parts on 2 printed pages using barryvdh/laravel-snappy?

77 views Asked by At

I am using barryvdh/laravel-snappy to create and download pdf files as shown below. Because the data sheet was too long, it went down to the second page but lost the lines at the top. How can I fix it? example images

1

There are 1 answers

0
Jeyhun Rashidov On BEST ANSWER

The content inside the tag will be treated as the body of the table:

<table>
    <thead>
        <tr>
            <th>Header 1</th>
            <th>Header 2</th>
            // ...
        </tr>
    </thead>
    <tbody>
        // ...
    </tbody>
   <tfoot>
        //...
   </tfoot>
</table>

Use the following CSS styles to ensure that the headers in the section are repeated on every page:

thead {
    display: table-header-group;
}

tfoot {
    display: table-footer-group;
}

tr {
    page-break-inside: avoid;
}

Make sure that when you're generating the PDF, you're using appropriate page dimensions and margins so that the content doesn't get cut off:

$pdf = PDF::loadView('your.view', $data)
           ->setOption('margin-top', 30)
           ->setOption('margin-bottom', 30);