I have a product list and I use in css at
var dishByCategory = _.groupBy(menu.dishes, d => d.categoryName);
var mywindow = window.open('', 'PRINT', 'height=auto,width=auto'); //Create window for print
mywindow.document.write('<html><head><title>' + menu.name + '</title>');
mywindow.document.write('<style>' +
'body{text-align: right; font-family: calibri; }' +
'h1{text-align: center;}' +
'h2{text-align: center; text-decoration: underline; direction: rtl;}' +
'h3{margin: 0.2cm;}' +
'h4{font-size: 22px; margin: 0cm 3cm;}' +
'.menuList{margin: 0cm 5cm;}' +
'@media print { .content{ page-break-inside: avoid; } }' +
'.logo{text-align: center; height: 5cm;}' +
'.footer{text-align: center; height: 3cm; font-family: times new roman;}' +
'img{height: 5cm; width: auto; }' +
'</style>');
mywindow.document.write('</head><body >');
mywindow.document.write('<div class="A4">'); //start of A4
for (let cat of menu.categories) {
var categoryDishes = dishByCategory[cat.categoryName];
var includeDishes = categoryDishes.filter(d => { return !d.extraPrice })
var notIncludeDishes = categoryDishes.filter(d => { return d.extraPrice })
mywindow.document.write('<div class="content">'); //start of content
mywindow.document.write('<br><h1>' + menu.name + ' - ' + cat.categoryName + '</h1>');
if (cat.dishesCount) {
mywindow.document.write('<h2> ' + cat.dishesCount + ' type to select</h2>');
}
mywindow.document.write('<div class="menuList">');
for (let dish of includeDishes)
{
mywindow.document.write('<h3>' + dish.name + '</h3>');
}
mywindow.document.write('</div>');
if (notIncludeDishes.length > 0)
{
mywindow.document.write('<h4>some title</h4>');
mywindow.document.write('<div class="menuList">');
for (let dish of notIncludeDishes) {
mywindow.document.write('<h3>' + dish.name + '</h3>');
}
mywindow.document.write('</div>');
}
mywindow.document.write('</div>'); //end of content
}
mywindow.document.write('</div>'); //end of A4
mywindow.document.write('</body></html>');
for each product div. it's start a new page if the div overfllow to the next page. I want to add header and footer in each page. how can i know which created a new page?
edit the header height is 5cm and footer: 3cm, so the solution from here not relevant. there the header and footer take just the white space on page.. I want to margin the body but only in first div each page