Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TCPDF: HTML table and page breaks

Tags:

php

tcpdf

I am creating a large HTML table and I have problem with page breaks as you can see in the following image:
enter image description here
Is there a method settle down the problem automatically? Or what is the way to do it?

like image 254
Koney Avatar asked May 01 '11 03:05

Koney


People also ask

How do I prevent page breaks within a table row?

Make sure all parent elements are display: block . Also consider overriding table , tr , td 's display styles with CSS grid for the print layout if you keep having issues with the table.

How do I split a page in a table?

When you insert a manual page break (Ctrl+Enter) in a table, you split the table, and the empty paragraph is the result. To create a page break without splitting the table (which also allows your heading row(s) to repeat), apply the "Page break before" property to the row you want to appear on a new page.

How do I add a page in Tcpdf?

Use $tcpdf->AddPage() to break page manually in your code. When you set SetAutoPageBreak(TRUE, 10); that means: when the height of document reach to (bottom - 10) then move the cursor to new page. So if you want to have more space, just reduce the number into 0.

How do I set header margins in Tcpdf?

What you actually want to do is to change the top margin of the main "container". Look in TCPDF config file for: define ('PDF_MARGIN_TOP', 19); Changing the value should solve the problem.


1 Answers

Try adding this to your <tr> tags: nobr="true".

So a quick example would be:

<table>     <tr nobr="true">         <td>Test</td>         <td>Test 2</td>     </tr> </table> 

The nobr="true" prevents the table rows from ever breaking apart. You can also put this on <td> and <th> tags.

like image 179
FastTrack Avatar answered Sep 20 '22 12:09

FastTrack