Click here to Skip to main content
15,886,110 members
Articles / Web Development / ASP.NET
Tip/Trick

Report Viewer Print Problem in Chrome, Mozilla Browsers

Rate me:
Please Sign up or sign in to vote.
3.40/5 (5 votes)
10 Jul 2012CPOL1 min read 69.6K   2.9K   7   20
Report Viewer print issue in Chrome / Mozilla / Safari: A solution where you can print report contents inside Report Viewer in any browser.

Sample Image

Introduction

Report Viewer print issue in Chrome / Mozilla / Safari browser solved.

Background

In the case of Chrome or Mozilla or in Safari, we can not get print option for Report Viewer to print the report content inside the viewer. Everyone tries a custom control or ActiveX control to get the print option enabled for the Report Viewer. Instead of that we can simply add a jQuery function for getting the contents of a report to print directly.

Using the code

Given below is code to get print facility for Report Viewer in a very simple manner:

//call printdiv() function on button click
<input name="b_print" type="button" onclick="printdiv();" value=" Print Report" />
//function for print
function printdiv() {
   //Code for adding HTML content to report viwer
    var headstr = "<html><head><title></title></head><body>";
    //End of body tag
    var footstr = "</body></html>";
    //This the main content to get the all the html content inside the report viewer control
    //"ReportViewer1_ctl10" is the main div inside the report viewer
    //controls who helds all the tables and divs where our report contents or data is available
    var newstr = $("#ReportViewer1_ctl10").html();
    //open blank html for printing
    var popupWin = window.open('', '_blank');
    //paste data of printing in blank html page
    popupWin.document.write(headstr + newstr + footstr);
    //print the page and see is what you see is what you get
    popupWin.print(); 
    return false;
}

Language used is C# done in ASP.NET 4.0 using jQuery and JavaScript.

Points of Interest

You can use Report Viewer version 8.0/9.0/10.0. The thing you have to do is always find the ID of your div inside Report Viewer. If you get the ID, you can directly use it else if div is inside an iFrame then find the iFrame first and then the div where your report data resides.

If your report appears inside IFrame, then go though this code. The main thing for this code is tracking your div which contains the data.

JavaScript
//call printdiv() function on button click
<input name="b_print" type="button" onclick="printdiv();" value=" Print Report" />
//function for print
    function printdiv() {
        //Code for adding HTML content to report viwer
        var headstr = "<html><head><style>.a86{border:1pt None Black;" + 
           "background-color:Transparent;background-repeat:Repeat;padding-left:2pt;" + 
           "padding-top:2pt;padding-right:2pt;padding-bottom:2pt;font-style:Normal;" + 
           "font-family:Arial;font-size:10pt;font-weight:Normal;text-decoration:None;" + 
           "direction:LTR;unicode-bidi:Normal;text-align:left;writing-mode:lr-tb;" + 
           "vertical-align:Top;color:Black;}.a5_s{WIDTH:146.05mm;HEIGHT:6.35mm;" + 
           "font-style:Normal;font-family:Arial;font-size:10pt;font-weight:Normal;" + 
           "text-decoration:None;direction:LTR;unicode-bidi:Normal;text-align:Center;" + 
           "writing-mode:lr-tb;vertical-align:Top;color:Black;}.a5{border:1pt None Black;" + 
           "background-color:Transparent;background-repeat:Repeat;padding-left:0pt;" + 
           "padding-top:0pt;padding-right:0pt;padding-bottom:0pt;HEIGHT:6.35mm;" + 
           "overflow:hidden;WIDTH:146.05mm}.a92{border:1pt None Black;" + 
           "background-color:Transparent;background-repeat:Repeat;padding-left:0pt;" + 
           "padding-top:0pt;padding-right:0pt;padding-bottom:0pt;WIDTH:114.30mm}.a96{" + 
           "border:1pt None Black;background-color:Transparent;background-repeat:" + 
           "Repeat;padding-left:0pt;padding-top:0pt;padding-right:0pt;padding-bottom:0pt;" + 
           "WIDTH:114.30mm}.a98{border:1pt None Black;background-color:Transparent;" + 
           "background-repeat:Repeat;padding-left:0pt;padding-top:0pt;padding-right:0pt;" + 
           "padding-bottom:0pt;WIDTH:38.10mm;HEIGHT:19.05mm;overflow:hidden}.a99" + 
           "{border:1pt None Black;background-color:Transparent;background-repeat:" + 
           "Repeat;padding-left:0pt;padding-top:0pt;padding-right:0pt;padding-bottom:0pt;" + 
           "font-style:Normal;font-family:Arial;font-size:12pt;font-weight:700;" + 
           "text-decoration:None;direction:LTR;unicode-bidi:Normal;text-align:Left;" + 
           "writing-mode:lr-tb;vertical-align:Top;color:Black;}.a100{border:1pt None Black;" + 
           "background-color:Transparent;background-repeat:Repeat;padding-left:0pt;padding-top:" + 
           "0pt;padding-right:0pt;padding-bottom:0pt;font-style:Normal;font-family:Arial;" + 
           "font-size:10pt;font-weight:Normal;text-decoration:None;direction:LTR;unicode-bidi:" + 
           "Normal;text-align:Left;writing-mode:lr-tb;vertical-align:Top;color:Black;}." + 
           "a101{border:1pt None Black;background-color:Transparent;background-repeat:Repeat;" + 
           "padding-left:0pt;padding-top:0pt;padding-right:0pt;padding-bottom:0pt;" + 
           "font-style:Normal;font-family:Arial;font-size:10pt;font-weight:Normal;" + 
           "text-decoration:None;direction:LTR;unicode-bidi:Normal;text-align:left;" + 
           "writing-mode:lr-tb;vertical-align:Top;color:Black;}.a102{border:1pt None Black;" + 
           "background-color:Transparent;background-repeat:Repeat;padding-left:0pt;" + 
           "padding-top:0pt;padding-right:0pt;padding-bottom:0pt;font-style:Normal;" + 
           "font-family:Arial;font-size:10pt;font-weight:Normal;text-decoration:None;" + 
           "direction:LTR;unicode-bidi:Normal;text-align:Left;writing-mode:lr-tb;" + 
           "vertical-align:Top;color:Black;}.a103{border:1pt None Black;background-color" + 
           ":Transparent;background-repeat:Repeat;padding-left:0pt;padding-top:0pt;" + 
           "padding-right:0pt;padding-bottom:0pt;font-style:Normal;font-family:Arial;" + 
           "font-size:10pt;font-weight:Normal;text-decoration:None;direction:LTR;" + 
           "unicode-bidi:Normal;text-align:Left;writing-mode:lr-tb;vertical-align:Top;color:Black;}" + 
           ".a85{border:1pt None Black;background-color:Transparent;background-repeat:Repeat;" + 
           "padding-left:2pt;padding-top:2pt;padding-right:2pt;padding-bottom:2pt;font-style:Normal;" + 
           "font-family:Arial;font-size:11pt;font-weight:700;text-decoration:None;direction:LTR;" + 
           "unicode-bidi:Normal;text-align:Center;writing-mode:lr-tb;vertical-align:Top;color:Black;" + 
           "}.a6{border:1pt None Black;background-color:Transparent;background-repeat:Repeat;" + 
           "padding-left:0pt;padding-top:0pt;padding-right:0pt;padding-bottom:0pt;border" + 
           "-collapse:collapse}.a76{border:1pt None Black;border-top-style:Solid;border" + 
           "-bottom-style:Solid;background-color:Transparent;background-repeat:Repeat;" + 
           "padding-left:2pt;padding-top:2pt;padding-right:2pt;padding-bottom:2pt;font" + 
           "-style:Normal;font-family:Arial;font-size:9pt;font-weight:700;text-decoration" + 
           ":None;direction:LTR;unicode-bidi:Normal;text-align:Left;writing-mode:lr-tb;" + 
           "vertical-align:Top;color:Black;word-wrap:break-word}.a77{border:1pt None " + 
           "Black;border-top-style:Solid;border-bottom-style:Solid;background-color:" + 
           "Transparent;background-repeat:Repeat;padding-left:2pt;padding-top:2pt;padding" + 
           "-right:2pt;padding-bottom:2pt;font-style:Normal;font-family:Arial;font-size:" + 
           "9pt;font-weight:700;text-decoration:None;direction:LTR;unicode-bidi:Normal;" + 
           "text-align:Left;writing-mode:lr-tb;vertical-align:Top;color:Black;word-wrap" + 
           ":break-word}.a78{border:1pt None Black;border-top-style:Solid;border-bottom" + 
           "-style:Solid;background-color:Transparent;background-repeat:Repeat;padding" + 
           "-left:2pt;padding-top:2pt;padding-right:2pt;padding-bottom:2pt;font-style" + 
           ":Normal;font-family:Arial;font-size:9pt;font-weight:700;text-decoration" + 
           ":None;direction:LTR;unicode-bidi:Normal;text-align:Left;writing-mode" + 
           ":lr-tb;vertical-align:Top;color:Black;word-wrap:break-word}.a79{border" + 
           ":1pt None Black;border-top-style:Solid;border-bottom-style:Solid;" + 
           "background-color:Transparent;background-repeat:Repeat;padding-left" + 
           ":2pt;padding-top:2pt;padding-right:2pt;padding-bottom:2pt;font-style" + 
           ":Normal;font-family:Arial;font-size:9pt;font-weight:700;text-decoration" + 
           ":None;direction:LTR;unicode-bidi:Normal;text-align:Left;writing-mode" + 
           ":lr-tb;vertical-align:Top;color:Black;word-wrap:break-word}.a80{border" + 
           ":1pt None Black;border-top-style:Solid;border-bottom-style:Solid;" + 
           "background-color:Transparent;background-repeat:Repeat;padding-left" + 
           ":2pt;padding-top:2pt;padding-right:2pt;padding-bottom:2pt;font-style" + 
           ":Normal;font-family:Arial;font-size:9pt;font-weight:700;text-decoration" + 
           ":None;direction:LTR;unicode-bidi:Normal;text-align:Left;writing-mode" + 
           ":lr-tb;vertical-align:Top;color:Black;word-wrap:break-word}.a81{border" + 
           ":1pt None Black;border-top-style:Solid;border-bottom-style:Solid;" + 
           "background-color:Transparent;background-repeat:Repeat;padding-left" + 
           ":2pt;padding-top:2pt;padding-right:2pt;padding-bottom:2pt;font-style" + 
           ":Normal;font-family:Arial;font-size:9pt;font-weight:700;text-decoration" + 
           ":None;direction:LTR;unicode-bidi:Normal;text-align:Left;writing-mode" + 
           ":lr-tb;vertical-align:Top;color:Black;word-wrap:break-word}.a82{border" + 
           ":1pt None Black;border-top-style:Solid;border-bottom-style:Solid;" + 
           "background-color:Transparent;background-repeat:Repeat;padding-left" + 
           ":2pt;padding-top:2pt;padding-right:2pt;padding-bottom:2pt;font-style" + 
           ":Normal;font-family:Arial;font-size:9pt;font-weight:700;text-decoration" + 
           ":None;direction:LTR;unicode-bidi:Normal;text-align:Left;writing-mode" + 
           ":lr-tb;vertical-align:Top;color:Black;word-wrap:break-word}.a83{border" + 
           ":1pt None Black;border-top-style:Solid;border-bottom-style:Solid;background" + 
           "-color:Transparent;background-repeat:Repeat;padding-left:2pt;padding-top:2pt;" + 
           "padding-right:2pt;padding-bottom:2pt;font-style:Normal;font-family:Arial;font-" + 
           "size:9pt;font-weight:700;text-decoration:None;direction:LTR;unicode-bidi:Normal;" + 
           "text-align:Left;writing-mode:lr-tb;vertical-align:Top;color:Black;word-wrap:" + 
           "break-word}.a84{border:1pt None Black;border-top-style:Solid;border-bottom-" + 
           "style:Solid;background-color:Transparent;background-repeat:Repeat;padding-left" + 
           ":2pt;padding-top:2pt;padding-right:2pt;padding-bottom:2pt;font-style:Normal;font" + 
           "-family:Arial;font-size:9pt;font-weight:700;text-decoration:None;direction:LTR;" + 
           "unicode-bidi:Normal;text-align:Left;writing-mode:lr-tb;vertical-align:Top;color:" + 
           "Black;word-wrap:break-word}.a17{border:1pt None Black;border-top-style:" + 
           "Solid;border-bottom-style:Solid;background-color:Transparent;background-repeat" + 
           ":Repeat;padding-left:2pt;padding-top:2pt;padding-right:2pt;padding-bottom:2pt;" + 
           "font-style:Normal;font-family:Arial;font-size:10pt;font-weight:700;text-decoration:" + 
           "None;direction:LTR;unicode-bidi:Normal;text-align:Left;writing-mode:lr-tb;vertical-align:" + 
           "Top;color:Black;word-wrap:break-word}.a18{border:1pt None Black;border-" + 
           "top-style:Solid;border-bottom-style:Solid;background-color:Transparent;" + 
           "background-repeat:Repeat;padding-left:2pt;padding-top:2pt;padding-right:2pt;" + 
           "padding-bottom:2pt;font-style:Normal;font-family:Arial;font-size:10pt;font-weight:" + 
           "Normal;text-decoration:None;direction:LTR;unicode-bidi:Normal;text-align:Left;" + 
           "writing-mode:lr-tb;vertical-align:Top;color:Black;word-wrap:break-word}.a19" + 
           "{border:1pt None Black;border-top-style:Solid;border-bottom-style:Solid;" + 
           "background-color:Transparent;background-repeat:Repeat;padding-left:2pt;" + 
           "padding-top:2pt;padding-right:2pt;padding-bottom:2pt;font-style:Normal;" + 
           "font-family:Arial;font-size:10pt;font-weight:Normal;text-decoration:None;" + 
           "direction:LTR;unicode-bidi:Normal;text-align:Left;writing-mode:lr-tb;" + 
           "vertical-align:Top;color:Black;word-wrap:break-word}.a20{border:1pt None Black;border" + 
           "-top-style:Solid;border-bottom-style:Solid;background-color:Transparent;" + 
           "background-repeat:Repeat;padding-left:2pt;padding-top:2pt;padding-right:2pt;" + 
           "padding-bottom:2pt;font-style:Normal;font-family:Arial;font-size:10pt;" + 
           "font-weight:Normal;text-decoration:None;direction:LTR;unicode-bidi:Normal;" + 
           "text-align:Left;writing-mode:lr-tb;vertical-align:Top;color:Black;word-wrap" + 
           ":break-word}.a21{border:1pt None Black;border-top-style:Solid;border-" + 
           "bottom-style:Solid;background-color:Transparent;background-repeat:Repeat;" + 
           "padding-left:2pt;padding-top:2pt;padding-right:2pt;padding-bottom:2pt;" + 
           "font-style:Normal;font-family:Arial;font-size:10pt;font-weight:Normal;" + 
           "text-decoration:None;direction:LTR;unicode-bidi:Normal;text-align:Left;" + 
           "writing-mode:lr-tb;vertical-align:Top;color:Black;word-wrap:break-word}.a22{border:" + 
           "1pt None Black;border-top-style:Solid;border-bottom-style:Solid;background-color" + 
           ":Transparent;background-repeat:Repeat;padding-left:2pt;padding-top:2pt;padding" + 
           "-right:2pt;padding-bottom:2pt;font-style:Normal;font-family:Arial;font-size:10pt;" + 
           "font-weight:Normal;text-decoration:None;direction:LTR;unicode-bidi:Normal;" + 
           "text-align:Left;writing-mode:lr-tb;vertical-align:Top;color:Black;word-wrap:" + 
           "break-word}.a23{border:1pt None Black;border-top-style:Solid;border-bottom" + 
           "-style:Solid;background-color:Transparent;background-repeat:Repeat;padding" + 
           "-left:2pt;padding-top:2pt;padding-right:2pt;padding-bottom:2pt;font-style:" + 
           "Normal;font-family:Arial;font-size:10pt;font-weight:Normal;text-decoration" + 
           ":None;direction:LTR;unicode-bidi:Normal;text-align:Left;writing-mode:lr-tb;" + 
           "vertical-align:Top;color:Black;word-wrap:break-word}.a35{border:1pt None Black;" + 
           "border-bottom-style:Solid;background-color:Transparent;background-" + 
           "repeat:Repeat;padding-left:2pt;padding-top:2pt;padding-right:2pt;padding-" + 
           "bottom:2pt;font-style:Normal;font-family:Arial;font-size:9pt;font-weight:Normal;" + 
           "text-decoration:None;direction:LTR;unicode-bidi:Normal;text-align:Left;writing-mode" + 
           ":lr-tb;vertical-align:Top;color:Black;word-wrap:break-word}.a36{border:1pt None Black;" + 
           "border-bottom-style:Solid;background-color:Transparent;background-repeat:Repeat;" + 
           "padding-left:2pt;padding-top:2pt;padding-right:2pt;padding-bottom:2pt;font-style" + 
           ":Normal;font-family:Arial;font-size:9pt;font-weight:Normal;text-decoration:None;" + 
           "direction:LTR;unicode-bidi:Normal;text-align:Left;writing-mode:lr-tb;vertical-" + 
           "align:Top;color:Black;word-wrap:break-word}.a37{border:1pt None Black;border-" + 
           "bottom-style:Solid;background-color:Transparent;background-repeat:Repeat;padding" + 
           "-left:2pt;padding-top:2pt;padding-right:2pt;padding-bottom:2pt;font-style:Normal;" + 
           "font-family:Arial;font-size:9pt;font-weight:Normal;text-decoration:None;direction:" + 
           "LTR;unicode-bidi:Normal;text-align:Left;writing-mode:lr-tb;vertical-align:Top;color" + 
           ":Black;word-wrap:break-word}.a38{border:1pt None Black;border-bottom-style:Solid" + 
           ";background-color:Transparent;background-repeat:Repeat;padding-left:2pt;padding-" + 
           "top:2pt;padding-right:2pt;padding-bottom:2pt;font-style:Normal;font-family:Arial;" + 
           "font-size:9pt;font-weight:Normal;text-decoration:None;direction:LTR;unicode-bidi" + 
           ":Normal;text-align:Left;writing-mode:lr-tb;vertical-align:Top;color:Black;word-" + 
           "wrap:break-word}.a39{border:1pt None Black;border-bottom-style:Solid;background-" + 
           "color:Transparent;background-repeat:Repeat;padding-left:2pt;padding-top:2pt;padding" + 
           "-right:2pt;padding-bottom:2pt;font-style:Normal;font-family:Arial;font-size:9pt;" + 
           "font-weight:Normal;text-decoration:None;direction:LTR;unicode-bidi:Normal;text-align" + 
           ":Left;writing-mode:lr-tb;vertical-align:Top;color:Black;word-wrap:break-word}" + 
           ".a40{border:1pt None Black;border-bottom-style:Solid;background-color:Transparent;" + 
           "background-repeat:Repeat;padding-left:2pt;padding-top:2pt;padding-right:2pt;" + 
           "padding-bottom:2pt;font-style:Normal;font-family:Arial;font-size:9pt;font-weight:" + 
           "Normal;text-decoration:None;direction:LTR;unicode-bidi:Normal;text-align:Left;" + 
           "writing-mode:lr-tb;vertical-align:Top;color:Black;word-wrap:break-word}.a41{" + 
           "border:1pt None Black;border-bottom-style:Solid;background-color:Transparent;" + 
           "background-repeat:Repeat;padding-left:2pt;padding-top:2pt;padding-right:2pt;" + 
           "padding-bottom:2pt;font-style:Normal;font-family:Arial;font-size:9pt;font-weight" + 
           ":Normal;text-decoration:None;direction:LTR;unicode-bidi:Normal;text-align:Left;" + 
           "writing-mode:lr-tb;vertical-align:Top;color:Black;word-wrap:break-word}.a42" + 
           "{border:1pt None Black;border-bottom-style:Solid;background-color:Transparent;" + 
           "background-repeat:Repeat;padding-left:2pt;padding-top:2pt;padding-right:2pt;" + 
           "padding-bottom:2pt;font-style:Normal;font-family:Arial;font-size:9pt;font-weight" + 
           ":Normal;text-decoration:None;direction:LTR;unicode-bidi:Normal;text-align:Left;" + 
           "writing-mode:lr-tb;vertical-align:Top;color:Black;word-wrap:break-word}.a43" + 
           "{border:1pt None Black;border-bottom-style:Solid;background-color:Transparent;" + 
           "background-repeat:Repeat;padding-left:2pt;padding-top:2pt;padding-right:2pt;" + 
           "padding-bottom:2pt;font-style:Normal;font-family:Arial;font-size:9pt;font-weight" + 
           ":Normal;text-decoration:None;direction:LTR;unicode-bidi:Normal;text-align:Left" + 
           ";writing-mode:lr-tb;vertical-align:Top;color:Black;word-wrap:break-word}.a55{border" + 
           ":1pt None Black;border-bottom-style:None;background-color:Transparent;background" + 
           "-repeat:Repeat;padding-left:2pt;padding-top:2pt;padding-right:2pt;padding-bottom" + 
           ":2pt;font-style:Normal;font-family:Arial;font-size:9pt;font-weight:Normal;" + 
           "text-decoration:None;direction:LTR;unicode-bidi:Normal;text-align:Left;" + 
           "writing-mode:lr-tb;vertical-align:Top;color:Black;word-wrap:break-word}" + 
           ".a56{border:1pt None Black;background-color:Transparent;background-repeat:" + 
           "Repeat;padding-left:2pt;padding-top:2pt;padding-right:2pt;padding-bottom:" + 
           "2pt;font-style:Normal;font-family:Arial;font-size:9pt;font-weight:Normal;" + 
           "text-decoration:None;direction:LTR;unicode-bidi:Normal;text-align:Left;" + 
           "writing-mode:lr-tb;vertical-align:Top;color:Black;word-wrap:break-word}." + 
           "a57{border:1pt None Black;background-color:Transparent;background-repeat:" + 
           "Repeat;padding-left:2pt;padding-top:2pt;padding-right:2pt;padding-bottom:" + 
           "2pt;font-style:Normal;font-family:Arial;font-size:10pt;font-weight:Normal;" + 
           "text-decoration:None;direction:LTR;unicode-bidi:Normal;text-align:Left;" + 
           "writing-mode:lr-tb;vertical-align:Top;color:Black;word-wrap:break-word}" + 
           ".a58{border:1pt None Black;background-color:Transparent;background-repeat" + 
           ":Repeat;padding-left:2pt;padding-top:2pt;padding-right:2pt;padding-bottom" + 
           ":2pt;font-style:Normal;font-family:Arial;font-size:9pt;font-weight:Normal;" + 
           "text-decoration:None;direction:LTR;unicode-bidi:Normal;text-align:Left;" + 
           "writing-mode:lr-tb;vertical-align:Top;color:Black;word-wrap:break-word}" + 
           ".a59{border:1pt None Black;background-color:Transparent;background-repeat" + 
           ":Repeat;padding-left:2pt;padding-top:2pt;padding-right:2pt;padding-bottom" + 
           ":2pt;font-style:Normal;font-family:Arial;font-size:9pt;font-weight:Normal;" + 
           "text-decoration:None;direction:LTR;unicode-bidi:Normal;text-align:Left;" + 
           "writing-mode:lr-tb;vertical-align:Top;color:Black;word-wrap:break-word}." + 
           "a60{border:1pt None Black;border-bottom-style:None;background-color:" + 
           "Transparent;background-repeat:Repeat;padding-left:2pt;padding-top:2pt" + 
           ";padding-right:2pt;padding-bottom:2pt;font-style:Normal;font-family" + 
           ":Arial;font-size:10pt;font-weight:Normal;text-decoration:None;direction" + 
           ":LTR;unicode-bidi:Normal;text-align:Left;writing-mode:lr-tb;vertical" + 
           "-align:Top;color:Black;word-wrap:break-word}.a61{border:1pt None Black" + 
           ";background-color:Transparent;background-repeat:Repeat;padding-left" + 
           ":2pt;padding-top:2pt;padding-right:2pt;padding-bottom:2pt;font-style" + 
           ":Normal;font-family:Arial;font-size:9pt;font-weight:Normal;text-" + 
           "decoration:None;direction:LTR;unicode-bidi:Normal;text-align:Left;" + 
           "writing-mode:lr-tb;vertical-align:Top;color:Black;word-wrap:break-word}" + 
           ".a62{border:1pt None Black;background-color:Transparent;background-" + 
           "repeat:Repeat;padding-left:2pt;padding-top:2pt;padding-right:2pt;" + 
           "padding-bottom:2pt;font-style:Normal;font-family:Arial;font-size:" + 
           "10pt;font-weight:Normal;text-decoration:None;direction:LTR;unicode" + 
           "-bidi:Normal;text-align:Left;writing-mode:lr-tb;vertical-align:Top;" + 
           "color:Black;word-wrap:break-word}.a63{border:1pt None Black;background" + 
           "-color:Transparent;background-repeat:Repeat;padding-left:2pt;padding-" + 
           "top:2pt;padding-right:2pt;padding-bottom:2pt;font-style:Normal;font-" + 
           "family:Arial;font-size:9pt;font-weight:Normal;text-decoration:None;" + 
           "direction:LTR;unicode-bidi:Normal;text-align:Left;writing-mode:lr-tb;" + 
           "vertical-align:Top;color:Black;word-wrap:break-word}.a87{border:1pt " + 
           "None Black;border-top-style:Dotted;background-color:Transparent;" + 
           "background-repeat:Repeat;padding-left:0pt;padding-top:0pt;padding-" + 
           "right:0pt;padding-bottom:0pt;WIDTH:100%}.a90{border:1pt None Black;" + 
           "background-color:Transparent;background-repeat:Repeat;padding-left:2pt;" + 
           "padding-top:2pt;padding-right:2pt;padding-bottom:2pt;font-style:Normal;" + 
           "font-family:Arial;font-size:9pt;font-weight:Normal;text-decoration:None;" + 
           "direction:LTR;unicode-bidi:Normal;text-align:Left;writing-mode:lr-tb;" + 
           "vertical-align:Top;color:Black;}.a89{border:1pt None Black;background-" + 
           "color:Transparent;background-repeat:Repeat;padding-left:2pt;padding-" + 
           "top:2pt;padding-right:2pt;padding-bottom:2pt;font-style:Normal;font-" + 
           "family:Arial;font-size:9pt;font-weight:Normal;text-decoration:None;" + 
           "direction:LTR;unicode-bidi:Normal;text-align:Right;writing-mode:lr-" + 
           "tb;vertical-align:Top;color:Black;}.r1{HEIGHT:100%;WIDTH:100%}." + 
           "r2{HEIGHT:100%;WIDTH:100%;overflow:hidden}.r3{HEIGHT:100%}.r4{" + 
           "border-style:none}.r5{border-left-style:none}.r6{border-right-" + 
           "style:none}.r7{border-top-style:none}.r8{border-bottom-style:none}." + 
           "r10{border-collapse:collapse}.r9{border-collapse:collapse;table-layout" + 
           ":fixed}.r11{WIDTH:100%;overflow-x:hidden}.r12{position:absolute;display" + 
           ":none;background-color:white;border:1px solid black;}.r13{text-decoration:" + 
           "none;color:black;cursor:pointer;}</style><title></title></head><body>";
        //End of body tag
        var footstr = "</body></html>";
        //ReportFramecntPlcHolder_ReportViewer1 is the id of Iframe where yor report content div resides
        $("#ReportFramecntPlcHolder_ReportViewer1").each(function () {
            //report is the id of frameset where yor report content div resides
            $("#report", this.contentWindow.document || this.contentDocument).each(function () {
                //oReportDiv is the id of div where yor report content resides
                var newstr = $("#oReportDiv", this.contentWindow.document || this.contentDocument).html();
                //document.body.innerHTML = headstr + newstr + footstr;
                //window.print();
                //open blank html for printing
                var popupWin = window.open('', '_blank');
                //paste data of printing in blank html page
                popupWin.document.write(headstr + newstr + footstr);
                //print the page and see is what you see is what you get
                popupWin.print(); 
            });

        });
        return false;
    }

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
Questionit's now getting the report with formatting (just text) Pin
Muhammad S. Eltyar31-Jul-18 9:47
Muhammad S. Eltyar31-Jul-18 9:47 
QuestionPopup window print does not display Pin
BERNADETTE G. ENCINAS 1-Nov-16 23:09
BERNADETTE G. ENCINAS 1-Nov-16 23:09 
SuggestionAlso, you can use the PrintToPrinter method of the report object Pin
Miguel Angel Heredia Moreno22-May-15 6:37
Miguel Angel Heredia Moreno22-May-15 6:37 
GeneralRe: Also, you can use the PrintToPrinter method of the report object Pin
Muhammad S. Eltyar31-Jul-18 9:26
Muhammad S. Eltyar31-Jul-18 9:26 
QuestionData is null Pin
Member 1088944711-Mar-15 21:40
Member 1088944711-Mar-15 21:40 
QuestionThanks..it's works.. Pin
Kinjal Sucess7-Mar-14 0:32
Kinjal Sucess7-Mar-14 0:32 
GeneralMy vote of 1 Pin
Carlo Ingrassia6-Nov-13 2:29
Carlo Ingrassia6-Nov-13 2:29 
QuestionReport data not view Pin
Hasitha Wijesooriya2-Jul-13 22:41
Hasitha Wijesooriya2-Jul-13 22:41 
QuestionReport data not view Pin
Hasitha Wijesooriya2-Jul-13 22:40
Hasitha Wijesooriya2-Jul-13 22:40 
GeneralMy vote of 4 Pin
Sarvesh Kushwaha19-Nov-12 1:04
Sarvesh Kushwaha19-Nov-12 1:04 
GeneralMy vote of 3 Pin
itzwiki16-Nov-12 19:41
itzwiki16-Nov-12 19:41 
QuestionDoes it print 'all' pages from the report? Pin
EricGeerts8-Nov-12 3:20
EricGeerts8-Nov-12 3:20 
AnswerRe: Does it print 'all' pages from the report? Pin
itzwiki16-Nov-12 19:42
itzwiki16-Nov-12 19:42 
AnswerRe: Does it print 'all' pages from the report? Pin
Sajith Dilhan8-Oct-13 22:54
Sajith Dilhan8-Oct-13 22:54 
GeneralRe: Does it print 'all' pages from the report? Pin
GaryParkin23-Jun-14 9:04
GaryParkin23-Jun-14 9:04 
AnswerRe: Does it print 'all' pages from the report? Pin
Member 970964014-Jan-15 21:40
Member 970964014-Jan-15 21:40 
GeneralRe: Does it print 'all' pages from the report? Pin
Miguel Angel Heredia Moreno22-May-15 6:35
Miguel Angel Heredia Moreno22-May-15 6:35 
QuestionProblem Pin
Member 36593674-Nov-12 22:50
Member 36593674-Nov-12 22:50 
QuestionPRINT BUTTON IN SSRS IN CHROME Pin
Member 365936731-Oct-12 22:19
Member 365936731-Oct-12 22:19 
GeneralMy vote of 5 Pin
Nilesh Patil Kolhapur12-Jul-12 20:57
Nilesh Patil Kolhapur12-Jul-12 20:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.