15

I am using SQL Reporting services, it's working perfectly and shows a print button in IE, but not shown in Mozilla Firefox.

Does anyone have any idea?

I have checked out this solution, but it's not working:

http://social.msdn.microsoft.com/Forums/en-US/vsreportcontrols/thread/7bdf431d-70db-419d-8e98-ef41cad8e2d8

3
  • That is not a solution, it is just stating that local mode printing is not implemented in Report Services 2005. Commented Jun 4, 2009 at 14:41
  • @Muhammad Akhtar: What is your SQL Server edition and version? Commented Jun 4, 2009 at 15:29
  • I am using SQL Express Edition and 2008 version Commented Jun 5, 2009 at 5:05

5 Answers 5

11

I don't think it uses ActiveX, because in the table onclick event there is a simple:

ReportFramerpvReport.GetReportFrame().contentWindow.print() 

Anyway, i replaced this print stuff with my own print function, because this code above wasn't working on FF..

I know it's ugly...but it works! (just replace the ControlName value with your ControlID and be sure to add jQuery lib in your page)

 $(document).ready(function() { if ($.browser.mozilla) { try { var ControlName = 'RptDespesas'; var innerScript = '<scr' + 'ipt type="text/javascript">document.getElementById("' + ControlName + '_print").Controller = new ReportViewerHoverButton("' + ControlName + '_print", false, "", "", "", "#ECE9D8", "#DDEEF7", "#99BBE2", "1px #ECE9D8 Solid", "1px #336699 Solid", "1px #336699 Solid");</scr' + 'ipt>'; var innerTbody = '<tbody><tr><td><input type="image" style="border-width: 0px; padding: 2px; height: 16px; width: 16px;" alt="Print" src="/Reserved.ReportViewerWebControl.axd?OpType=Resource&amp;Version=9.0.30729.1&amp;Name=Microsoft.Reporting.WebForms.Icons.Print.gif" title="Print"></td></tr></tbody>'; var innerTable = '<table title="Print" onmouseout="this.Controller.OnNormal();" onmouseover="this.Controller.OnHover();" onclick="PrintFunc(\'' + ControlName + '\'); return false;" id="' + ControlName + '_print" style="border: 1px solid rgb(236, 233, 216); background-color: rgb(236, 233, 216); cursor: default;">' + innerScript + innerTbody + '</table>' var outerScript = '<scr' + 'ipt type="text/javascript">document.getElementById("' + ControlName + '_print").Controller.OnNormal();</scr' + 'ipt>'; var outerDiv = '<div style="display: inline; font-size: 8pt; height: 30px;" class=" "><table cellspacing="0" cellpadding="0" style="display: inline;"><tbody><tr><td height="28px">' + innerTable + outerScript + '</td></tr></tbody></table></div>'; $("#" + ControlName + " > div > div").append(outerDiv); } catch (e) { alert(e); } } }); function PrintFunc(ControlName) { setTimeout('ReportFrame' + ControlName + '.print();', 100); } 
Sign up to request clarification or add additional context in comments.

5 Comments

Now I don't have the project, that have the above problem. because I have changed company, but your solution is good. that's why I am up voting. Thanks
I think it will work for 1page but it won't work for many page! any solution?
How do I use this? Do I need to copy or make my own PRINT button to trigger the above script? And what do you mean by ControlName? What control? If I cannot see a print button then there is no control to trigger the code. Obviously I am a noob
@Israel Rodriguez What is Control Name? My report Name? Please help
@Af'faq I don't remember the details, but there's something in the line of inspecting the generated HTML to check the actual ID, the answer from Sachin may help also.
5

The above solution was not working for me, so I made the following changes to the above solution after inspecting the rendered html.

ReportViewerGeneral_ctl05 -> id of the pager
VisibleReportContentReportViewerGeneral_ctl09 -> id of the div that contained the result of the report.
pageLoad -> refer this

function pageLoad() { if ($.browser.mozilla && !$("#ff_print").length) { try { var ControlName = 'ReportViewerGeneral'; var innerTbody = '<tbody><tr><td><input type="image" style="border-width: 0px; padding: 2px; height: 16px; width: 16px;" alt="Print" src="/Reserved.ReportViewerWebControl.axd?OpType=Resource&amp;Version=9.0.30729.1&amp;Name=Microsoft.Reporting.WebForms.Icons.Print.gif" title="Print"></td></tr></tbody>'; var innerTable = '<table title="Print" onclick="PrintFunc(\'' + ControlName + '\'); return false;" id="ff_print" style="border: 1px solid rgb(236, 233, 216); background-color: rgb(236, 233, 216); cursor: default;">' + innerTbody + '</table>' var outerDiv = '<div style="display: inline; font-size: 8pt; height: 30px;" class=" "><table cellspacing="0" cellpadding="0" style="display: inline;"><tbody><tr><td height="28px">' + innerTable + '</td></tr></tbody></table></div>'; $("#ReportViewerGeneral_ctl05 > div").append(outerDiv); } catch (e) { alert(e); } } } function PrintFunc() { var strFrameName = ("printer-" + (new Date()).getTime()); var jFrame = $("<iframe name='" + strFrameName + "'>"); jFrame .css("width", "1px") .css("height", "1px") .css("position", "absolute") .css("left", "-2000px") .appendTo($("body:first")); var objFrame = window.frames[strFrameName]; var objDoc = objFrame.document; var jStyleDiv = $("<div>").append($("style").clone()); objDoc.open(); objDoc.write($("head").html()); objDoc.write($("#VisibleReportContentReportViewerGeneral_ctl09").html()); objDoc.close(); objFrame.print(); setTimeout(function () { jFrame.remove(); }, (60 * 1000)); } 

1 Comment

Just want to add that this appends the print button twice. Use document.ready instead of function pageload(...
2

If you're offering export functionality via the ReportViewer, the user can still export to PDF and print that. Not as efficient/slick as a one-click print button, but it's an easy work around.

Comments

1

I've made a solution which emulates the entire print button from IE to other browsers.

https://stackoverflow.com/a/37455354/1253835

Comments

-1

Not a solution but a bit of info.

I use SSRS quite regularily for internal projects as i know the target audience are all using IE, but i do not use it for external web facing apps as i have had so many problems with it in FF (date pickers not working etc), although i have never looked at the print button options i suspect this may be a similar problem (report viewer control designed only for IE!) as it seems to affect the toolbar in general.

Going off this http://www.windows-tech.info/15/5fb0fd315e07edf8.php it seems that some activex controls are used and FF doesn't do activeX natively although i do remember a plugin that allowed activex controls to be loaded but where i saw that i can't remember.

EDIT: http://www.iol.ie/~locka/mozilla/plugin.htm I've never used it and can't vouch for it but there is a plugin here.

For web facing projects i tend to use Crystal!

HTH

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.