Madhav
Madhav

Reputation: 569

How to get the print Prieview of page with window.print()?

Here I am trying to get the print preview of page using button like:

<input type="button" value="Print in javascript" onclick="window.print();"/>

It is working in seome percentage. But I am not getting 100% print preview, it drops some content while prieviwing.

Is there any thing which I am not doing correctly?

Upvotes: 0

Views: 82

Answers (1)

Zorken17
Zorken17

Reputation: 1896

Have you tried to put everything you want to print in a media query in CSS:

@media print {
    .myDivToPrint {
        background-color: white;
        height: 100%;
        width: 100%;
        position: fixed;
        top: 0;
        left: 0;
        margin: 0;
        padding: 15px;
        font-size: 14px;
        line-height: 18px;
    }
}

Upvotes: 2

Related Questions