Forum How do I...?

Prevent hidden overflow from appearing on the next page?

whittaker007
All the text in my document is placed inside fixed-size containers set to overflow: hidden in the CSS. This seems to function for a given page - the overflowed text is cut off at the end of the box as expected. However in a few cases the overflowed text causes an extra page to be inserted with a copy of the container blocks and the last few lines of the overflowed text inside.

Is there any way to prevent this from happening?
mikeday
Odd. Are you able to create a simplified test document which demonstrates this problem? That would make it easier for us to track down and either explain (if it's not a bug) or fix (if it is).
whittaker007
OK, here's the simplest page which exhibits the behaviour. There are two columns floated left, each containing three content spots, which are all fixed width and height and set to overflow: hidden.

When content overflows either or both of the last two blocks by more than a couple of lines, the bottom two blocks are repeated on a new page and part of the overflowed text appears in them.

As an experiment I overflowed the text in the middle left block and nothing happens until the overflowed text is longer than the page height - or would be if it wasn't hidden. So the behaviour seems to be triggered by overflowing the page height.

Also when this happened, it pushed the right column to the next page, duplicated the overflowed block to the left column of the second page, followed by the bottom left block.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:svg="http://www.w3.org/2000/svg"
      xmlns:xlink="http://www.w3.org/1999/xlink"
      xml:lang="en-nz" lang="en-nz">
   <head>
      <title>PDF source</title>
      <link rel="stylesheet" type="text/css" media="print" href="print.css" />
   </head>

   <body>
      <div id="container">
         <div>

            <div class="pagelayout">
               <div class="zone Left">
                  <div class="spot s2">
                     <div class="element_image"><img src="/sites/all/files/s2-3.jpg" /></div>
                  </div>
                  <div class="spot s2">
                     <div class="element_text">
                        <h4>Size 2 block 1</h4>
                        <p>Size 2 block 1 article text.</p>
                     </div>
                  </div>
                  <div class="spot s4_tall">
                     <div class="element_text">
                        <h4>Size 4 block 3</h4>
                        <p>Size 4 block 3 article text. Size 4 block 3 article text. Size 4 block 3 article text. Size 4 block 3 article text. Size 4 block 3 article text. Size 4 block 3 article text. Size 4 block 3 article text. Size 4 block 3 article text. Size 4 block 3 article text. Size 4 block 3 article text. Size 4 block 3 article text. Size 4 block 3 article text. Size 4 block 3 article text. Size 4 block 3 article text. Size 4 block 3 article text. Size 4 block 3 article text. Size 4 block 3 article text. Size 4 block 3 article text. Size 4 block 3 article text. Size 4 block 3 article text. Size 4 block 3 article text. Size 4 block 3 article text. Size 4 block 3 article text. Size 4 block 3 article text. Size 4 block 3 article text. Size 4 block 3 article text. Size 4 block 3 article text. Size 4 block 3 article text. Size 4 block 3 article text. Size 4 block 3 article text. Size 4 block 3 article text. Size 4 block 3 article text. Size 4 block 3 article text. Size 4 block 3 article text. Size 4 block 3 article text. Size 4 block 3 article text. Size 4 block 3 article text. Size 4 block 3 article text. Size 4 block 3 article text. Size 4 block 3 article text. Size 4 block 3 article text. Size 4 block 3 article text. Size 4 block 3 article text. Size 4 block 3 article text. Size 4 block 3 article text. Size 4 block 3 article text. Size 4 block 3 article text. Size 4 block 3 article text. Size 4 block 3 article text. Size 4 block 3 article text. Size 4 block 3 article text. Size 4 block 3 article text. Size 4 block 3 article text. Size 4 block 3 article text. Size 4 block 3 article text. Size 4 block 3 article text.</p>
                     </div>
                  </div>
               </div>
               <div class="zone Right">
                  <div class="spot s4_tall">
                     <div class="element_text">
                        <h4>Size 4 block 2</h4>
                        <p>Size 4 block 2 article text.</p>
                     </div>
                  </div>
                  <div class="spot s2">
                     <div class="element_image"><img src="/sites/all/files/s2-1.png" /></div>
                  </div>
                  <div class="spot s2">
                     <div class="element_text">
                        <h4>Size 2 block 2</h4>
                        <p>Size 2 block 2 article text. Size 2 block 2 article text. Size 2 block 2 article text. Size 2 block 2 article text. Size 2 block 2 article text. Size 2 block 2 article text. Size 2 block 2 article text. Size 2 block 2 article text. Size 2 block 2 article text. Size 2 block 2 article text. Size 2 block 2 article text. Size 2 block 2 article text. Size 2 block 2 article text. Size 2 block 2 article text. Size 2 block 2 article text. Size 2 block 2 article text. Size 2 block 2 article text. Size 2 block 2 article text. Size 2 block 2 article text. Size 2 block 2 article text. Size 2 block 2 article text. Size 2 block 2 article text. Size 2 block 2 article text. Size 2 block 2 article text. Size 2 block 2 article text. Size 2 block 2 article text. Size 2 block 2 article text. Size 2 block 2 article text. </p>
                     </div>
                  </div>
               </div>
            </div>

         </div>
      </div>
   </body>
</html>


print.css
/* Generic styles first */
p { color: black; }
h4 { color: black; font-weight: bold; }

/* Pages */
@page { 
   size: A4;
   margin: 0;
   marks: crop cross;
   prince-bleed: 5mm;
}

.pagelayout {
   position: relative; overflow: hidden;
   width: 210mm; height: 297mm;
   background: #F9F9F9; border: 1mm solid black;
}

.pagename { display: none; }

/* Zones */
.zone {
   position: relative; overflow: hidden;
   background: #CCC; border: 0.5mm solid #999;
}

.Header, .Footer, .Top, .Middle, .Bottom
   { clear: both; }

.Left, .Centre, .Right
   { width: auto; float: left; }
	
/* Spots */
.spot {
	position: relative; overflow: hidden;
	margin: 8mm 0 0 8mm;
	background: white; border: 0.5mm dashed black;
}

.s2 { width: 90mm; height: 60mm; }
.s4_tall { width: 90mm; height: 127mm; }

.Header .spot, .Footer .spot, .Top .spot, .Middle .spot, .Bottom .spot
   { float: left; }

.element_text { background: #FFC; }
.element_image { background: #CFF; }
mikeday
This is undesirable behaviour, we will fix it in the next release of Prince by ensuring that blocks with a specified height cannot be repeated across page breaks.
mickyjtwin
I believe my new post about last row overflowing is related to this. Is this fixed in the latest download? If not, when would this come into effect?
mikeday
We have released a first beta version of Prince 7.0 which should solve this issue.
cepdadministrator
mikeday wrote:
We have released a first beta version of Prince 7.0 which should solve this issue.


Hello, we are experiencing this same problem with Prince 7.1

Basically, the last DIV on the page (the one closest to the page bottom) will have its contents flowed in full to the top of the next page even though the overflow is hidden, and max-height, height, are all set and would normally stop the content at the bottom of the page. If the DIV with the same content appears elsewhere on the page, it is clipped at its height as one would expect.

Can you please let me know if this is still expected behaviour for Prince 7.1 . thank you
mikeday
Is there actually enough space for it? eg. if the height/max-height are set to 2cm, is there at least 2cm of available space at the bottom of the page?
cepdadministrator
mikeday wrote:
Is there actually enough space for it? eg. if the height/max-height are set to 2cm, is there at least 2cm of available space at the bottom of the page?


Hello, I believe there is enough space, unless I am missing some fine measurements. The @page is defined as Letter. The @page is defined as a top/bottom 1inch margin, left/right .25 inch margin.

The DIV in question is the third row of divs of 3 inches in height, with a min-height, max-height and height all 3in. and a width of 4in. There is no border.

They are actually badges, so there are 6 of these divs on the page.

The six DIVs are Row 1, Left + Right, Row 2 , Left + Right, Row 3 Left + Right.

When the bottom right DIV has too much text, it overflows to the next page. I have not tested the bottom left DIV but that will never have "too much" text just because of what we use it for.

It works like a charm as long as Row 3 Right Div has less text.

Below are the actual styles.

thanks!



@page { size: Letter;
margin-top:1in;
margin-bottom:1in;
margin-left:0.25in;
margin-right:0.25in;
}


body {
background: white;
font-size: 12pt;

}

div.label_left_standard {
clear: both;
float: left;
width: 4in;
min-height: 3in;
max-height: 3in;
height: 3in;
text-align: center;
margin: 0;
overflow: hidden;
background: white url(url_to_template.png) no-repeat 0 0;
}

div.label_right_standard {
float: right;
width: 4in;
min-height: 3in;
max-height: 3in;
height: 3in;
margin: 0;
overflow: hidden;
}
mikeday
Perhaps reduce the page margin a fraction. If you leave exactly 9" of page body height, and you have three divs of 3" each, then even the smallest rounding error could cause a div to get moved to the next page.