Click here to Skip to main content
15,887,485 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want to print a rdlc report in asp.net.I try it with javascript but its style changed.Please help me

What I have tried:

function Print() {
    var report = document.getElementById("<%=ReportViewer1.ClientID %>");
    var div = report.getElementsByTagName("DIV");
    var reportContents;
    for (var i = 0; i < div.length; i++) {
        if (div[i].id.indexOf("VisibleReportContent") != -1) {
            reportContents = div[i].innerHTML;
            break;
        }
    }
    var frame1 = document.createElement('iframe');
    frame1.name = "frame1";
    //frame1.style.position = "absolute";
    //frame1.style.top = "-1000000px";
    //document.body.appendChild(frame1);
    var frameDoc =  frame1.contentDocument.document;
    frameDoc.document.open();
    //frameDoc.document.write('<html><head><title>RDLC Report</title>');
    //frameDoc.document.write('</head><body style = "font-family:arial;font-size:10pt;">');
    frameDoc.document.write(reportContents);
    //frameDoc.document.write('</body></html>');
    frameDoc.document.close();
    setTimeout(function () {
        window.frames["frame1"].focus();
        window.frames["frame1"].print();
        document.body.removeChild(frame1);
    }, 500);
}
         </script>
Posted
Updated 21-Jun-18 9:04am

1 solution

Walkthrough: Printing a Local Report without Preview

https://msdn.microsoft.com/en-us/library/ms252091.aspx
 
Share this answer
 
Comments
Member 10989733 22-Jun-18 0:43am    
It's windows based code...i am using web application...can u please help me..i want to print rdlc report

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