Click here to Skip to main content
15,886,519 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have Print button my page, which is executing window.print() so onclick of print button I want the same output which I am getting on page but while printing the page it is not coming as expected, please click on the below provided links for screenshots of output I am getting. Thanks in advance.

O/P on webpage: http://i.stack.imgur.com/fOkH7.png[^]

O/P on print preview page: http://i.stack.imgur.com/TAryy.png[^]


CSS
<html>
<head>
<style>
@media print {
.h6 {
    text-align: left;
    padding-left: 30px;
    position: relative;
    z-index: 2;
}

.line-center {
    margin: 0;
    padding: 0 10px;
    background: #fff;
    display: inline-block;
}

.h6:after {
    content: "";
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    border-top: solid 1px lightgrey;
    z-index: -1;
}
}
.h6 {
    text-align: left;
    padding-left: 30px;
    position: relative;
    z-index: 2;
}

.line-center {
    margin: 0;
    padding: 0 10px;
    background: #fff;
    display: inline-block;
}

.h6:after {
    content: "";
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    border-top: solid 1px lightgrey;
    z-index: -1;
}

<style>
<head>
<body>
<h6 class="h6"><span class="line-center">Hello StackOverflow</span></h6>
</body>
</html>


What I have tried:

I have included the css properties used in @media print but it is not applying.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900