How to use page-break and avoid white space to split my div over multiple pages

On my page I have some content loaded from my database. All this content is placed inside a DIV, nicely styled with images, font styles and background image. I want the visitor to be able to print this content without losing the styles.

I get everything to work nicely, except for the pagebreak. Somehow whatever I try, there’s always a small space placed beneath every div that makes my DIV result in a position slicely lower that it’s previous. In other words: the more page’s the content needs, the more of the DIV is cut into half and shown on the next page. See below for an illustration of my problem.

The CSS

[code]@media all {
.page-break {
display: none;
}

.wrapper_programmaker:after {
padding-top: 70.71%;
display: block ;
content: ‘’;
}
}

@media print {
.page-break {
display:inline-block; page-break-after: always;
}

.wrapper_programmaker:after {
padding-top: 70.71%;
margin-bottom: -0.9%;
display:block;
content: ‘’;
}
}

.main_programmaker {
position: absolute;
top: 0;
bottom: 0;
right: 0;
left: 0;
color: #282828;
font-family: ‘Frutiger’, sans-serif;
}[/code]

The PHP

[code]

<? mysqli_fetch_array { ?>
<div class="wrapper_programmaker">
  <div class="main_programmaker" style="background-image:url(../images/BG.jpg); background-repeat:no-repeat; background-size:contain;">

    //way more divs and content that are irrelevant for this question

  </div>
</div>
<? } ?>
[/code]

And the JS

function printDiv(printableArea) { var printContents = document.getElementById('printableArea').innerHTML; var originalContents = document.body.innerHTML; document.body.innerHTML = printContents; window.print(); document.body.innerHTML = originalContents; }

I don’t see a class with the name ‘page-break’.

In the PHP part it is on row 11. On the CSS it is on row 2 and 14

I would screw with the css. Try,

[php].page-break {
page-break-before: always;
}
[/php]

And see if there is a change.

Tried all posibilities, break-after -inside -before and all options but nothing works

margin-bottom: -0.9%;

Possibly an issue

Nope, I wrote this line so it would work on my personal computer. This % is the exact amount needed in order to do what I’d like to achieve on my computer. Unfortunately it’s not the way to make it work on every computer…

Sponsor our Newsletter | Privacy Policy | Terms of Service