I have reports in SSRS 2005. I am using remote reports. In IE, the print button shows, but in Firefox and Chrome, the print button does not show.
My reports are shown in jquery UI dialogs, so I cannot just do a window.print. My reports render just fine within the modals.
I need to be able to issue a print command to the reportviewer the same way it is done from within the control, but only in firefox and chrome.
I dug into the markup for the report viewer, and found this code. I tried to manually inject it into the reportviewer with no success.
<table id="reportViewer_ctl01_ctl07_ctl00_ctl00" onclick="document.getElementById('reportViewer').ClientController.LoadPrintControl();return false;" onmouseover="this.Controller.OnHover();" onmouseout="this.Controller.OnNormal();" title="Print" style="display:none;">
<script type="text/javascript">
document.getElementById('reportViewer_ctl01_ctl07_ctl00_ctl00').Controller = new ReportViewerHoverButton("reportViewer_ctl01_ctl07_ctl00_ctl00", false, "", "", "", "#ECE9D8", "#DDEEF7", "#99BBE2", "1px #ECE9D8 Solid", "1px #336699 Solid", "1px #336699 Solid");
</script><tr>
<td><input type="image" name="reportViewer$ctl01$ctl07$ctl00$ctl00$ctl00" title="Print" src="/Reserved.ReportViewerWebControl.axd?OpType=Resource&Version=9.0.30729.4402&Name=Microsoft.Reporting.WebForms.Icons.Print.gif" alt="Print" style="height:16px;width:16px;padding:2px;" /></td>
</tr>
</table>
Any ideas?
Here's what I did to create a pseudo print button which emulates the print function of Report Viewer in Internet Explorer to other browsers.
Please take note that the solution below requires JQuery. No ActiveX installation is necessary.
Here are the steps.
Step 1. Add the print button in your page where the report viewer is situated.
Be sure to change the Version number to your RS version. If you're having trouble with the html code, you can open the page with internet explorer and inspect the print element and copy it.
Step 2. Add a div where your PDF will be rendered.
Step 3. Add the script.
Code explanation :
First we created a variable which detects if the browser is IE or not.
By using the _getInternalViewer() method in Reserved.ReportViewerWebControl.axd we can request a PDF version of the report as a request which is originally retrieved upon clicking the export button.
We then assigned a contentDisposition variable as 'AlwaysInline' because we want to request the report as a PDF, not as an attachment but as a PDF that we can render in an html element. https://msdn.microsoft.com/en-us/library/microsoft.reporting.webforms.reportviewer.exportcontentdisposition.aspx
The src_new variable replaces the default EXPORT button content disposition request (which is set to AlwaysAttachment by default) with our new request 'AlwaysInline'.
Next, we then set the src of the iframe to our new url which when loaded, will reveal our report from reportviewer as PDF.
The chained commands in the iframe includes hiding the pdf element, rendering it and printing it right away after it finishes loading the pdf.
Ending remarks
I hope that someone will find this code useful because I had a hard time finding a decent solution online and this is what I came up with after doing some research.
I made some changes with regards to the above and it works well for me in both Chrome and Firefox.
Unfortunately the print button is not supported in browsers other than IE.
I think you realise this and did a workaround, we have yet to come up with a decent solution as well. Although most of our users prefer printing from Excel directly, so we allow them to export the file which they then do the printing.
This SO question would be a good link:
SQL Reporting Services - Print Button not shown in Mozilla
Please find the code for SSRS report that has Print Icon with Printing functionality for Firefox and Chrome: