locked
SSRS print programatically RRS feed

  • Question

  • User-1909230013 posted

    Hi,

    How to print ths SSRS Report in programatically in asp.net 

    Friday, June 28, 2013 7:02 AM

Answers

  • User-1909230013 posted

    Hi Neo

     Ya i want to print it in client side. I found a temprory solution that is. Placed the reportviewer into the div and printed that using jquery...

    Java Script

     <script language="javascript" type="text/javascript" src="Scripts/jquery-1.4.1.min.js"></script>
    <script type="text/javascript">
        function printdiv(printpage) {
            var headstr = "<html><head><title></title></head><body>";
            var footstr = "</body></html>";
            var newstr = document.getElementById(printpage).innerHTML;
            var oldstr = document.getElementById("body1").innerHTML;
            document.getElementById("body1").innerHTML = headstr + newstr + footstr;
            window.print();
            document.getElementById("body1").innerHTML = oldstr;
            return false;
        }
     <div id="body1">
    
        <input name="b_print" type="button" class="ipt" onclick="printdiv('div_print');" value="Print" />
    <div id="div_print">
    
    <h1 style="Color:Red">The Div content which you want to print</h1>
    
    <rsweb:ReportViewer ID="ReportViewer1" runat="server" Width="944px" ShowPrintButton="true" SizeToReportContent="True" AsyncRendering="false" ></rsweb:ReportViewer>
    
    </div>
    //Other content you wouldn't like to print
    //Other content you wouldn't like to print
    </div>





    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, June 29, 2013 1:55 AM

All replies

  • User-1185172246 posted

    Do you want to print the report to the client printer? Do you want to preview the report or just print it without doing that?

    Friday, June 28, 2013 8:49 AM
  • User-1909230013 posted

    Hi Neo

     Ya i want to print it in client side. I found a temprory solution that is. Placed the reportviewer into the div and printed that using jquery...

    Java Script

     <script language="javascript" type="text/javascript" src="Scripts/jquery-1.4.1.min.js"></script>
    <script type="text/javascript">
        function printdiv(printpage) {
            var headstr = "<html><head><title></title></head><body>";
            var footstr = "</body></html>";
            var newstr = document.getElementById(printpage).innerHTML;
            var oldstr = document.getElementById("body1").innerHTML;
            document.getElementById("body1").innerHTML = headstr + newstr + footstr;
            window.print();
            document.getElementById("body1").innerHTML = oldstr;
            return false;
        }
     <div id="body1">
    
        <input name="b_print" type="button" class="ipt" onclick="printdiv('div_print');" value="Print" />
    <div id="div_print">
    
    <h1 style="Color:Red">The Div content which you want to print</h1>
    
    <rsweb:ReportViewer ID="ReportViewer1" runat="server" Width="944px" ShowPrintButton="true" SizeToReportContent="True" AsyncRendering="false" ></rsweb:ReportViewer>
    
    </div>
    //Other content you wouldn't like to print
    //Other content you wouldn't like to print
    </div>





    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, June 29, 2013 1:55 AM
  • User-1185172246 posted

    nice trick! Sometimes html printing becomes uncontrollable as each browser has its own "engine" for doing such thing. If you find in such situation, then one another possible solution is to rely on PDF format. You may export the report to PDF through code and then print it to the client printer. Printing output will be the same independently of the client browser. In this article it talks about doing such thing with a local report RDLC but you can make minor changes to make it to work with server reports RDL. Anyway, if your current trick is working, then stay with it. Cheers,

    Saturday, June 29, 2013 6:55 AM