I have an application which prints the html table using window.print()
, The application is working fine when i click the print hyperlink, the problem which i am facing is the page break up, I have goggled and found many solutions , majority of them uses css for resolving the issue, but when i tried the css as shown below its not working. A sample demo i have mocked up in JS-Fiddle to show the issue
Test it in chrome so that one can see the preview and use page size as A4 to view the page break.
@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%;
}
}