59

I'm working on a printable list of events, the printer prints one page fine, but cuts off some of the text on the bottom, then it print a second blank page

I've tried everything I know but am at a loss.

15 Answers15

73

In print.css, set overflow: visible instead of overflow: auto on div#content. That fixed it for me in Firefox at least. The definition of overflow auto is: "If overflow is clipped, a scroll-bar should be added to see the rest of the content" -- but scroll bars don't exist on printed pages.

I'm guessing that since the content div should span across multiple pages, the browser thinks "you're flowing outside your container and must be clipped with a scroll bar". The container in that case is the first page the content div appears on.

Zach Saucier
  • 24,871
  • 12
  • 85
  • 147
CalebD
  • 4,962
  • 24
  • 16
28

I know this is an old question but here's another, newer way this can happen.

Check if you're using display: flex; on the clipped element. It was the problem for me, setting it to block fixed it.

red-X
  • 5,108
  • 1
  • 25
  • 38
13

I found that setting display: inline on container divs also helped. Some of these great answers here have worked for me in certain situations while in others no.

<div class="container">
    <div class="content-cutting-off-here">
        Some long text that gets cut off at the end of the page...
    </div>
</div>

Most people set containers to display block or inline-block. For me it was cutting off text, and setting it to inline circumvented that. This also makes width and height irrelevant for the offending container div; which I have found to be a nuisance when printing.

@media print {
    .container {
        display: inline;
    }
}

Here is a great article that helped me with this solution.

Yes Barry
  • 9,514
  • 5
  • 50
  • 69
5

If any of the containers you're trying to print are floated, they'll get cut-off like you're seeing.

In your print.css, make sure you turn off all the floating that you can without destroying your layout. It's a pain, but browser support for printing is weak at best.

Pat
  • 25,237
  • 6
  • 71
  • 68
3

Are you already using the print value for the media attribute for your stylesheet like

<link rel="stylesheet" href="print.css" media="print" /> 

You might also want to use page-break-before attributes for elements that you don't want to break.

Randell
  • 6,112
  • 6
  • 45
  • 70
  • yes, the print stylesheet is definitely being used the page is really just a long list of tables, I don't really want a page break before each one –  Aug 21 '09 at 15:13
2

I just resolved this problem in ie7. This was in a Sharepoint project, which had various table cells and/or divs set to height:100%. When printed, it would print long forms, the first page or 2 would print as usual, then blank pages instead of the rest.

In my print stylesheet, I set those tables & divs to height: auto, and now it prints fine.

I'm having a different problem in IE8 now. UGH!

betsy
  • 21
  • 1
  • 2
1

if overflow:visible; not works, try overflow-y:visible;

(i had body{overflow-y:scroll;}, and body{overflow:visible;} in print.css not rewrited it...)

buTs
  • 41
  • 2
0

I just ran into this issue and have been scouring the internet for a solution that fit my specific needs. In my case I had about 7 tables nested in a larger table. The only way I was able to get the entire web page to print and display in print preview correctly was to use page breaks. Page breaks are CSS properties that allow you to specify and/or force page breaks by attaching the property to block elements.

https://developer.mozilla.org/en-US/docs/Web/CSS/page-break-before

Zach Johnson
  • 123
  • 9
0

just setting display: inline solved my same problem.

Reference link I got, https://www.bennadel.com/blog/851-fixing-divs-that-cause-content-truncation-when-printing.htm

0

I setup my print sheet to only print the modal content. My fix was to make the modal position: absolute;. My modal was originally position: fixed;.

0

For me setting overflow:visible; for body solved the problem.

body {
        overflow: visible;
}
Arash Younesi
  • 1,671
  • 1
  • 14
  • 23
0

I've had this issue to. In my case, this was due to an

position: fixed;

Element. I changed this to

@media print{
   position: relative;
}

Now I even see new elements that were behind my fixed element, and no cutting off at the bottom anymore.

DBR
  • 146
  • 1
  • 10
0

If the items on the page are getting partially cut off, adding an :after element of 10px did it for me.

<div class="print-row">
  <div class="print-items">
    <div class="print-item"></div>
    <div class="print-item"></div>
    <div class="print-item"></div>
  </div>
</div>
.print-items {
  page-break-before: auto;
  page-break-after: auto;
  page-break-inside: avoid;
}

.print-item {
  break-inside: avoid;
}

.print-item:after {
  position: relative;
  display: block;   
  min-width: 100%;
  height: 10px;
  width: 100%;
  content: "";
}
0

I fixed the problem by adding overflow:visible; and give it padding-right: 30px; to substitute for the scroll bars width.

Andrew Barber
  • 39,603
  • 20
  • 94
  • 123
Hassan
  • 1
-2

for me, the issue was this meta tag:

<meta name="viewport" content="width=device-width, initial-scale=1"/>

which putting any value other than 1 for initial scale solves my problem:

<meta name="viewport" content="width=device-width, initial-scale=0.8"/>
Abbas Sabeti
  • 141
  • 2
  • 9