Javascript:window.print() Prints 2 Pages While I Have 1
I have a simple HTML document which includes an image tag only. I want to print the image after document's loaded. my code:
Solution 1:
You can use CSS for controlling the image size, etc for print - using @media print
Give the image a max-width
.
That way, you can control how the image renders on the page. Example:
@media print {
bodyimg {
width: 90%; max-width: 1048px;
}
}
Solution 2:
Scale down the image a little bit and center it with margin.
<imgsrc="form1.jpg"width="90%"style="margin:auto;"/>
Solution 3:
You Can Make a iframe tag by js and Put Image On it Then Print only iframe.
I hope it Work
<iframe id="iframeprint" style="display:none"></iframe>
maybe You Need This js Code
access To inside Of iframe
document.getElementById('iframeprint').contentWindow.document.body.innerHTML=document.getElementById('form1');
print iframe only
document.getElementById('iframeprint').contentWindow.print() ;
Post a Comment for "Javascript:window.print() Prints 2 Pages While I Have 1"