Tiến Hoàng
Tiến Hoàng

Reputation: 17

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

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

Upvotes: 1

Views: 105

Answers (1)

Jeyhun Rashidov
Jeyhun Rashidov

Reputation: 1118

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);

Upvotes: 1

Related Questions