I played around with page-break-inside:auto, page-break-inside:avoid, page-break-after:auto, margin-top and margin-bottom
and others for quite a long time, but still can't find a solution how to break rows in my long HTML table, which is meant to be printed.
Page looks like the left screenshot in printing mode (or preview window before printing in Chrome):
All I need to achieve is to break every row at the bottom of each page, which is going to be devided on two pages (and its content too..)
This is a piece of code of my page:
...
<style>
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
td { padding-left: 15px; padding-right: 15px; }
@media print{
.netisk{
visibility: hidden;
}
}
@page{
size: 21cm 29.7cm;
margin: 0px;
}
body {
margin-left: 1cm;
margin-right: 1cm;
}
</style>
...
...
...
<?php
echo "<table cellspacing='0'><thead><tr><th> ID </th><th> Název projektu </th><th> Kategorie </th><th> Autor </th><th> Třída </th><th> Rok </th><th> Vedoucí práce </th></tr></thead><tbody>";
if (mysql_num_rows($result) > 0) {
while($row = mysql_fetch_assoc($result)) {
echo "<tr><td>" . $row["id"]. "</td><td>" . $row["nazev_projektu"]. "</td><td>" . $row["kategorie"]. "</td><td>" . $row["autor"]. "</td><td>" . $row["trida"]. "</td><td>" . $row["rok"]. "</td><td>" . $row["vedouci_prace"]. "</td></tr>";
}
}
echo "</tbody></table>";
mysql_close($mysql_conn);
?>
...
...
Page is here: http://student.spsbv.cz/krolop.el12a/mproj/components/tisk.php
As you can see, there is a problem, that my table "grows" dynamically depending on the count of data in my MySQL database, so it's hard to assign a specific row, where the table should be broken.
How to solve this?
EDIT: The given solution (How to apply CSS page-break to print a table with lots of rows?) didn't fix my issue, is there any different way (using HTML and CSS)?