Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is there such a discrepancy between Chrome print CSS emulation and Print Preview?

I have a Bootstrap 3-based site. Printing out certain pages is important to our customers. Most of the site prints acceptably, except for the modal dialogs.

I'm trying to use Chrome's (v42.0.2311.135 m) CSS print emulation to improve the print stylesheet. However, it looks nothing like Print Preview, or what actually comes out the printer.

I want the print version of the modals to cover the whole screen. Here's what I have so far:


Screen:

enter image description here


Print CSS emulation (looks good, modal takes up whole screen):

enter image description here


Print preview / actual hard copy (completely wrong - modal is small and I can see the rest of the page):

enter image description here

Here are the relevant bits of my print stylesheet:

@media print {
    * {
        -moz-transition: none !important;
        -o-transition: none !important;
        -webkit-transition: none !important;
        transition: none !important;
    }

    .modal-backdrop {
        background-color: white!important;
    }

    .modal.center .modal-dialog {
        width: 100%;
        max-width: 100%;
        height: 90%;

    }
}

How do I get the Print CSS emulation to resemble the actual printed output?

like image 338
Mike Chamberlain Avatar asked May 13 '15 04:05

Mike Chamberlain


People also ask

Is there a print preview on Chrome?

Using Google Chrome Print Preview When you find a page you want to print, go to the menu in the top-right corner or use the Ctrl + P shortcut. By default, you'll get to preview your page before it prints.

How do I change the print settings on Google Chrome?

Step 1: Click the three dots on the upper right corner of your Google Chrome browser to expand the More Options list. Step 2: Select Print. Step 3: Click on More Settings. Step 4: Select the correct paper size from the dropdown.


1 Answers

The css media: print in emulation is only for applying print css rules to the page, it does not account for all the other things that go along with print.

For instance, images and background colors do not print by default (which is why the main content is showing up, that bg-color:white is not applied). Other things can be issues, like absolute positioning. The only reliable way to test print is by actually printing, or at least printing to pdf.

It's also worth noting that there will be browser discrepancies in printing.

like image 89
Dylan Watt Avatar answered Sep 17 '22 13:09

Dylan Watt