Click here to Skip to main content
15,884,099 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
XML
when i click print button my data print in paper size as 5*4

how to set width and height
i am using java script for width and height to display dialog
i am written code is correct?

anyone provide example for this page resize to print in printer
kindly help me


function PrintPanel() {
            var panel = document.getElementById("<%=pnlContents.ClientID %>");
            var printWindow = window.open('', '', 'height=600,width=800');
            printWindow.document.write('<html><head><title>DIV Contents</title>');
            printWindow.document.write('</head><body >');
            printWindow.document.write(panel.innerHTML);
            printWindow.document.write('</body></html>');
            printWindow.document.close();


            setTimeout(function () {
                printWindow.print();
                printWindow.resizeTo(500,400);
                printWindow.focus();
                printwindow.window.close();


            }, 500);


            return false;
        }
Posted

1 solution

What are you doing here is setting the size of the printWindow, it has nothing to do with the paper size you are printing on!
In fact you can not set printer properties from JavaScript.
what you can do is using CSS selector code>@page to format the page for printer: https://developer.mozilla.org/en-US/docs/Web/CSS/@page[^]
 
Share this answer
 

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