How to avoid page break in table with rowspan on print - html

I have problem when printing my page which contain table in html. It's break into new page even it's still inside the same row. How do i prevent this?
This is how my print preview looks like.

Try this:
#media print {
tr {
page-break-inside: avoid !important;
}
}

Related

print preview table bad stacking?

I have table with many row. It's too long for the snippet so i provide the jsfiddle . Basically is html table with many row and structured with
<table>
<thead>text here!</thead>
<tbody>
inside this is td with many tr structure, rowspan and colspan
</tbody>
All i want is :
Thead always appear on the top of the print paper
i want automatically page break of the first tr (MODEL as the starter td)
I already has the solution for the first problem, but why it's look so ugly (some td has stacking problem on the next paper) and get inside the thead? i confused with this...
And if possible, is there any solution for page-break? i already searching all the answer but it must done manually to the which tr should on another page. But i want to automatically doing page break on start tr of MODEL
Thank you, i know my question is basic... but i really stuck here.
You can try scaling out your page using the #page property of CSS3
Your code would somewhat look like this
#media print {
#page {
size: 21cm 29.7cm;
margin: 30mm 45mm 30mm 45mm;
}
tr,td { page-break-before: always; }
}
Hope it helps!

css - Printed page text goes outside the block on page break

So i have this generated page i want to print - http://hubog-2017.com/print_prog_en
I break the page after each table. In the second table, one of the texts is too long and it breaks into two pages (Pages 2 and 3). Now the problem is that the text gets outside its TD and i see it on the THEAD.
I tried using word-breaks and padding's with no success.
Managed to get a partial solution by adding this CSS:
Its not exactly how i wanted it to look but at least the text is not breaking...
#page {
size: A4;
}
#media print {
html, body {
width: 210mm;
height: 297mm;
}
}

html - verify that each div will be on separated print page

I have many divs that proposed to be printed - on different pages.
How can I make sure that when the user is clicking the print button, each div will be on a different page?
Thanks!
You can use the page-break-after attribute in the print media query. The advantage is, that you don't have to change the size of your divs, it just makes sure that the page break will be after the div.
#media print {
div {
page-break-after: always;
}
}
More information about page-break-after on MDN.
In css, there is a media query you can use to specifically format your web page for when you want to print it:
#media print {
/* insert your style declarations here */
div {
page-break-after: always; /* ensures the next will we appear on new page */
}
}
You can use this media query to make each div fill up an entire page when the user decides to print. You can use this to modify things like removing the navbar when the user decides to print.
On the other hand, to avoid direct breaks after a certain element use page-break-after: avoid;
You can also for the use to print in a certain format that you want to specify using the follow:
#page {
size: A4; /* or A4 landscape or A5 */
}

two extra blank page add when printing

I am using using a CSS property for printing,
two extra page always added in my print. for this I tried these thing:-
.print:last-child {
page-break-after: auto;
}
but this is not working
I am also tried:-
html, body {
height: auto;
}
but problem is still there.
and when I using this:-
.print{
page-break-after: always
}
It prints an extra blank page before
please add page-break-after: avoid or page-break-before: avoid and you can reduce element spacing it also affect. if you give me url/js fiddle link it will be easier to fix issue. i have also hanged many times on print version

page-break-inside doesn't work with hidden table

I some CSS similar to this:
table#id {
display : none;
}
#media print {
table#id {
display : block;
}
.no-page-break {
page-break-inside: avoid !important;
}
}
Each td contains a div.no-page-break. The problem I'm having is that there are page breaks inside the tds unless the table is made visible before opening the print dialogue. If I emulate print media in the dev tools and print, it works fine. If I display the table before window.print() and hide it afterwards it also works, although I'd like to avoid this hack. Anyone have any ideas about why this is happening?