Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to achieve page break in HTML table for Google Chrome?

I am trying to print a large table generated with jQuery in an HTML page. I am using Chrome 26.0.141. The issue is with page break.

i initially used this css

#membersList table { page-break-inside:auto; position:relative}
#membersList tr { page-break-before:avoid; page-break-after:auto;position:relative}
#membersList td{ border:solid 1px #CCCCCC;width:auto;position:relative}
#membersList thead { display:table-header-group;position:relative }
#membersList tfoot { display:table-footer-group;positioion:relative} 

this dint worked so i searched and got this link Google Chrome Printing Page Breaks

based on one of the answer in that link i am using the following CSS attribute

 -webkit-region-break-inside: avoid;

But when I run and inspect the element, it is stroked out by default.

What would be the solution? There are lot of posts I searched. They say that recent versions don't support page break. If it's true then what other solution is there to achieve page break in Google Chrome?

like image 604
sarsarahman Avatar asked Dec 02 '22 18:12

sarsarahman


2 Answers

Finally I resolved this issue. I made tr{display:block;} and then I fixed the cell spacing.

Page break only works on block level elements.

like image 177
sarsarahman Avatar answered Dec 10 '22 12:12

sarsarahman


As said on MDN:

WebKit browsers doesn't support this property; but some have the non-standard -webkit-column-break-after and -webkit-region-break-after with similar parameters as page-break-after.

So you need to use page-break-after with some value which suits you the best. Here are some of them:

The page-break-after CSS property adjusts page breaks after the current element.

auto: Initial value. Automatic page breaks (neither forced nor forbidden).

always: Always force page breaks after the element.

avoid: Avoid page breaks after the element.

left: Force page breaks after the element so that the next page is formatted as a left page.

right: Force page breaks after the element so that the next page is formatted as a right page.

You can also use the break-after property:

The break-after CSS property describes how the page, column or region break behavior after the generated box. If there is no generated box, the property is ignored.

like image 34
Mohammad Areeb Siddiqui Avatar answered Dec 10 '22 11:12

Mohammad Areeb Siddiqui