I have an application that prints an html table using window.print(). The application works fine when I click on the hyperlink to print, the problem I encountered is page break, I studied and found many solutions, most of them use css to solve the problem, but when I tried css as below, it does not work. Sample demo I made fun of in JS-Fiddle to show the problem
Test it in chrome to preview it and use A4 page size to view page breaks.

Jsfiddle
@media print {
body * {
visibility: hidden;
}
div {
page-break-inside: avoid;
}
table {
page-break-after: always;
page-break-inside: auto;
}
tr {
page-break-inside: avoid;
page-break-after: auto;
}
td {
page-break-inside: avoid;
page-break-after: auto;
}
thead {
display: table-header-group;
}
tfoot {
display: table-footer-group;
}
#printSection * {
visibility: visible;
}
#printSection {
position: absolute;
top: 0;
left: 0;
right: 0;
margin: 0 auto;
width: 100%;
}
}