Shal

Shal

  • 1.4k
  • 240
  • 3.3k

RDLC ReportViewer Print preview not showing

Apr 5 2021 7:12 AM
I have added a button using javascript to preview and print but images are loaded into a Print preview.
 
The photos(images) are not appearing in the Print preview.
 
find the image attached for reference.
 
kindly check my code.
  1. <script type="text/javascript">  
  2. function printReport(report_ID) {  
  3. var rv1 = $('#' + report_ID);  
  4. var iDoc = rv1.parents('html');  
  5. // Reading the report styles  
  6. var styles = iDoc.find("head style[id$='ReportControl_styles']").html();  
  7. if ((styles == undefined) || (styles == '')) {  
  8. iDoc.find('head script').each(function () {  
  9. var cnt = $(this).html();  
  10. var p1 = cnt.indexOf('ReportStyles":"');  
  11. if (p1 > 0) {  
  12. p1 += 15;  
  13. var p2 = cnt.indexOf('"', p1);  
  14. styles = cnt.substr(p1, p2 - p1);  
  15. }  
  16. });  
  17. }  
  18. if (styles == '') { alert("Cannot generate styles, Displaying without styles.."); }  
  19. styles = '<style type="text/css">' + styles + "style>";  
  20. //--- Reading the report html  
  21. var table = rv1.find("div[id$='_oReportDiv']");  
  22. if (table == undefined) {  
  23. alert("Report source not found.");  
  24. return;  
  25. }  
  26. //-- Generating a copy of the report in a new window  
  27. var docType = '';  
  28. var docCnt = styles + table.parent().html();  
  29. var docHead = '<head><title>Printing ...title><style>body{margin:5;padding:0;}style>head>';  
  30. var winAttr = "location=yes, statusbar=no, directories=no, menubar=no, titlebar=no, toolbar=no, dependent=no, width=720, height=600, resizable=yes, screenX=200, screenY=200, personalbar=no, scrollbars=yes"; ;  
  31. var newWin = window.open("""_blank", winAttr);  
  32. var childWindow = window.open('Print.aspx''PrintMe''width=900,resizable=1,scrollbars=1');  
  33. writeDoc = newWin.document;  
  34. writeDoc.open();  
  35. writeDoc.write(docType + '<html>' + docHead + '<body onload="window.print();">' + docCnt + 'body>html>');  
  36. writeDoc.close();  
  37. // The print event will fire as soon as the window loads  
  38. newWin.focus();  
  39. // uncomment to autoclose the preview window when printing is confirmed or canceled.  
  40. // newWin.close();  
  41. };  
  42. function printReportClick() {  
  43. printReport('<%=ReportViewer1.ClientID %>');  
  44. }  
  45. </script>  
  46. <asp:Button runat="server" CssClass="btn-addschedule-bot"  
  47. Style="margin-left: 10px;" ID="btnPrint" CausesValidation="true"  
  48. ValidationGroup="vgSubmit" OnClientClick="printReportClick();"  
  49. Text="Print Report" />

Attachment: u.zip

Answers (3)