0

I'm using .rdlc report in my web application, exporting report to pdf & print it works great but now i wanted to print report automatically(i,e on click of print button.)

Is it possible to print rdlc report automatically?

Please help me, & thank you.

Sharanamma Jekeen
  • 881
  • 1
  • 8
  • 14

3 Answers3

1

Is it possible to print rdlc report automatically?

If you can render it on a page you can use javascript window.print(), that prints current window. So as sinni800 said render report on separate page.

Something like this,

on page with other content add this button :

<a href="javascript:window.open('/print-content.html','_blank');">print report</a>

First parameter of open window is page with your report viewer, and in that page you can start print on load event, like this :

<body id="top" onload="window.print();">
    rendered report here
</body>

But if you ask me better stick with your current solution.

You can save your report as PDF on disk, open it with Javscript and then print it, there is a example on Code Project for exactly your scenario as I understud you :

http://www.codeproject.com/Tips/376300/Custom-Print-functionality-for-Microsoft-Report-Vi

Antonio Bakula
  • 20,445
  • 6
  • 75
  • 102
1

Actually, in when you open your rdlc report in Internet Explorer report must have a button that does that printing job.

Alper
  • 771
  • 1
  • 9
  • 27
  • Yes your right Alper, but I'm mainly concentrated to work in chrome or in Mozilla because of my application added css will not support properly in explore. – Sharanamma Jekeen May 08 '12 at 06:09
0

If you are targeting Active-X enabled browsers (ex. IE) the following solution should work:

<script language="javascript"> 
     function PrintReport() { 
         var viewerReference = $find("ReportViewer1");

         var stillonLoadState = viewerReference.get_isLoading();

         if (!stillonLoadState ) { 
             var reportArea = viewerReference .get_reportAreaContentType(); 
             if (reportArea == Microsoft.Reporting.WebFormsClient.ReportAreaContent.ReportPage) { 
                 $find("ReportViewer1").invokePrintDialog(); 
             } 
         } 
     } 
 </script>

http://blogs.msdn.com/b/selvar/archive/2011/04/09/invoking-the-print-dialog-for-report-viewer-2010-control-using-the-javascript-api.aspx

Kindlyy note that this solution will not work on browsers that doesn't support Active-X