Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set automatic page breaks on TCPDF when a row in a table does not fit in the page?

Tags:

html

php

tcpdf

I made a table in TCPDF using html. Now, I need to determine if a table row will fit in the page since their height varies depending on the data they hold.

If the row's content won't fit because it has a big height or the row's content already reached past the footer, it will be instead printed to the next page. How can I achieve this? I'm still new to TCPDF.

Thanks for your help!

Example: (in this case, Employee 3 row doesn't fit because Employee 2 row's height is high and will be printed at the 2nd page)

Page 1

Employee Name || Earning || Deduction || Net Pay


Employee 1

                      - ALLOWANCE   - TAX           20,000.00
                      - N.SHIFT     - H. PLAN
                      - LUNCH ALW   - LOAN
                                    - LOAN 2
                                    - LOAN 3

Employee 2

                      - ALLOWANCE   - TAX           18,000.00
                      - N.SHIFT     - H. PLAN
                      - LUNCH ALW   - LOAN
                                    - LOAN 2
                                    - LOAN 3 
                                    - LOAN 4
                                    - LOAN 5 
                                    - LOAN 6
                                    - LOAN 7

Page 2

Employee Name || Earning || Deduction || Net Pay


Employee 3

                      - ALLOWANCE   - TAX           30,000.00
                      - LUNCH ALW   - H. PLAN
                                    - LOAN
                                    - LOAN 2
                                    - LOAN 3 
                                    - LOAN 4
                                    

like image 682
passerby Avatar asked Apr 20 '15 08:04

passerby


1 Answers

This might help you: TCPDF multipage table page break in multiline cell problem.

You just have to use following tag on each <tr> element.

<tr nobr="true">
  <td>your content here</td>
</tr>
like image 137
walkingRed Avatar answered Nov 16 '22 00:11

walkingRed