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. "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 = '' + 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 = 'Printing ...title><style>body{margin:5;padding:0;}style>head>'</span><span>;  </span></span></li><li class=""><span><span class="keyword">var</span><span> winAttr = </span><span class="string">"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"</span><span>; ;  </span></span></li><li class="alt"><span><span class="keyword">var</span><span> newWin = window.open(</span><span class="string">""</span><span>, </span><span class="string">"_blank"</span><span>, winAttr);  </span></span></li><li class=""><span><span class="keyword">var</span><span> childWindow = window.open(</span><span class="string">'Print.aspx'</span><span>, </span><span class="string">'PrintMe'</span><span>, </span><span class="string">'width=900,resizable=1,scrollbars=1'</span><span>);  </span></span></li><li class="alt"><span>writeDoc = newWin.document;  </span></li><li class=""><span>writeDoc.open();  </span></li><li class="alt"><span>writeDoc.write(docType + <span class="string">'<html>'</span><span> + docHead + </span><span class="string">'<body onload="window.print();">'</span><span> + docCnt + </span><span class="string">'body>html>'</span><span>);  </span></span></li><li class=""><span>writeDoc.close();  </span></li><li class="alt"><span><span class="comment">// The print event will fire as soon as the window loads</span><span>  </span></span></li><li class=""><span>newWin.focus();  </span></li><li class="alt"><span><span class="comment">// uncomment to autoclose the preview window when printing is confirmed or canceled.</span><span>  </span></span></li><li class=""><span><span class="comment">// newWin.close();</span><span>  </span></span></li><li class="alt"><span>};  </span></li><li class=""><span><span class="keyword">function</span><span> printReportClick() {  </span></span></li><li class="alt"><span>printReport(<span class="string">'<%=ReportViewer1.ClientID %>'</span><span>);  </span></span></li><li class=""><span>}  </span></li><li class="alt"><span></script>  </span></li><li class=""><span><asp:Button runat=<span class="string">"server"</span><span> CssClass=</span><span class="string">"btn-addschedule-bot"</span><span>  </span></span></li><li class="alt"><span>Style=<span class="string">"margin-left: 10px;"</span><span> ID=</span><span class="string">"btnPrint"</span><span> CausesValidation=</span><span class="string">"true"</span><span>  </span></span></li><li class=""><span>ValidationGroup=<span class="string">"vgSubmit"</span><span> OnClientClick=</span><span class="string">"printReportClick();"</span><span>  </span></span></li><li class="alt"><span>Text=<span class="string">"Print Report"</span><span> /></span></span></li></ol></div></div></article><section class="comments" id="replies"><header class="comments-head"><span class="comments-badge" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" width="19" height="19" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><path d="M3 3h10a2 2 0 0 1 2 2v4.5a2 2 0 0 1-2 2H7.5L4 14.5V11.5H3a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z"></path></svg></span><div><h2 class="comments-title">3 Replies</h2><p class="comments-sub">Know the answer? Post it — somebody with the same question will find it here.</p></div></header><div class="comment-signin"><span class="comment-signin-badge" aria-hidden="true"><svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.6"><path d="M11.5 3.5h3.2a1 1 0 0 1 1 1v11a1 1 0 0 1-1 1h-3.2" stroke-linecap="round"></path><path d="M4.5 10h7" stroke-linecap="round"></path><path d="M8.8 7.2 11.6 10l-2.8 2.8" stroke-linecap="round" stroke-linejoin="round"></path></svg></span><div class="comment-signin-body"><p class="comment-signin-title">Sign in to <!-- -->answer this question</p><p class="comment-signin-text">It is the same account you read, post and publish with — and you will come straight back to this page.</p></div><div class="comment-signin-actions"><a class="btn primary-btn comment-signin-btn" href="/login?returnurl=%2Fforums%2Frdlc-reportviewer-print-preview-not-showing">Sign in</a><a class="comment-signin-alt" href="/register?returnurl=%2Fforums%2Frdlc-reportviewer-print-preview-not-showing">Create an account</a></div></div><ul class="comment-list"><li class="comment-thread"><article class="comment"><a class="comment-photo-link" href="/members/suraj-dubey" title="Suraj Dubey"><img class="comment-photo" src="https://cdn.c-sharpcorner.com/uploadfile/authorimage/0dc42c20200811105643.webp" alt="Suraj Dubey" title="Suraj Dubey" loading="lazy" data-avatar-name="Suraj Dubey" referrerPolicy="no-referrer"/></a><div class="comment-main"><div class="comment-head"><p class="comment-byline"><a href="/members/suraj-dubey" class="comment-author">Suraj Dubey</a><span class="posted-when" tabindex="0"><time class="posted-when-value comment-time" dateTime="2021-04-05T12:03:17.267Z">5y<!-- --> ago</time><span class="posted-when-pop" role="tooltip"><span>Posted<!-- --> <!-- -->Apr 5, 2021, 12:03 PM</span></span></span></p></div><div class="article-body">you can get idea from this video<br /><br />https://www.youtube.com/watch?v=YIrEw0UOA0Y</div><div class="comment-foot"><span class="reply-vote"><a href="/login?returnurl=%2Fforums%2Frdlc-reportviewer-print-preview-not-showing" class="reply-vote-btn reply-vote-up" title="Sign in to vote up" aria-label="Vote up"><svg width="14" height="14" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><path d="M8 2.5 14.5 12h-13z"></path></svg></a><span class="reply-vote-score" title="0 up, 0 down">0</span><a href="/login?returnurl=%2Fforums%2Frdlc-reportviewer-print-preview-not-showing" class="reply-vote-btn reply-vote-down" title="Sign in to vote down" aria-label="Vote down"><svg width="14" height="14" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><path d="M8 13.5 1.5 4h13z"></path></svg></a></span></div></div></article></li><li class="comment-thread"><article class="comment"><a class="comment-photo-link" href="/members/shalini-ravi2" title="Shal"><span class="comment-photo avatar-initials" title="Shal" style="background-image:linear-gradient(135deg, #e11d48 0%, #9f1239 100%);font-size:16px" aria-hidden="true">S</span></a><div class="comment-main"><div class="comment-head"><p class="comment-byline"><a href="/members/shalini-ravi2" class="comment-author">Shal</a><span class="posted-when" tabindex="0"><time class="posted-when-value comment-time" dateTime="2021-04-05T11:11:51.050Z">5y<!-- --> ago</time><span class="posted-when-pop" role="tooltip"><span>Posted<!-- --> <!-- -->Apr 5, 2021, 11:11 AM</span></span></span></p></div><div class="article-body forum-plain-text">tried this but images are not visible in browers and printer preview.</div><div class="comment-foot"><span class="reply-vote"><a href="/login?returnurl=%2Fforums%2Frdlc-reportviewer-print-preview-not-showing" class="reply-vote-btn reply-vote-up" title="Sign in to vote up" aria-label="Vote up"><svg width="14" height="14" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><path d="M8 2.5 14.5 12h-13z"></path></svg></a><span class="reply-vote-score" title="0 up, 0 down">0</span><a href="/login?returnurl=%2Fforums%2Frdlc-reportviewer-print-preview-not-showing" class="reply-vote-btn reply-vote-down" title="Sign in to vote down" aria-label="Vote down"><svg width="14" height="14" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><path d="M8 13.5 1.5 4h13z"></path></svg></a></span></div></div></article></li><li class="comment-thread"><article class="comment"><a class="comment-photo-link" href="/members/suraj-dubey" title="Suraj Dubey"><img class="comment-photo" src="https://cdn.c-sharpcorner.com/uploadfile/authorimage/0dc42c20200811105643.webp" alt="Suraj Dubey" title="Suraj Dubey" loading="lazy" data-avatar-name="Suraj Dubey" referrerPolicy="no-referrer"/></a><div class="comment-main"><div class="comment-head"><p class="comment-byline"><a href="/members/suraj-dubey" class="comment-author">Suraj Dubey</a><span class="posted-when" tabindex="0"><time class="posted-when-value comment-time" dateTime="2021-04-05T11:08:42.440Z">5y<!-- --> ago</time><span class="posted-when-pop" role="tooltip"><span>Posted<!-- --> <!-- -->Apr 5, 2021, 11:08 AM</span></span></span></p></div><div class="article-body">try this one it will help you<br /><br />https://www.aspsnippets.com/Articles/Print-RDLC-Report-without-Print-Preview-using-JavaScript-in-ASPNet.aspx</div><div class="comment-foot"><span class="reply-vote"><a href="/login?returnurl=%2Fforums%2Frdlc-reportviewer-print-preview-not-showing" class="reply-vote-btn reply-vote-up" title="Sign in to vote up" aria-label="Vote up"><svg width="14" height="14" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><path d="M8 2.5 14.5 12h-13z"></path></svg></a><span class="reply-vote-score" title="0 up, 0 down">0</span><a href="/login?returnurl=%2Fforums%2Frdlc-reportviewer-print-preview-not-showing" class="reply-vote-btn reply-vote-down" title="Sign in to vote down" aria-label="Vote down"><svg width="14" height="14" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><path d="M8 13.5 1.5 4h13z"></path></svg></a></span></div></div></article></li></ul></section></div></div><script>$RS=function(a,b){a=document.getElementById(a);b=document.getElementById(b);for(a.parentNode.removeChild(a);a.firstChild;)b.parentNode.insertBefore(a.firstChild,b);b.parentNode.removeChild(b)};$RS("S:2","P:2")</script><script>$RB=[];$RV=function(a){$RT=performance.now();for(var b=0;b<a.length;b+=2){var c=a[b],e=a[b+1];null!==e.parentNode&&e.parentNode.removeChild(e);var f=c.parentNode;if(f){var g=c.previousSibling,h=0;do{if(c&&8===c.nodeType){var d=c.data;if("/$"===d||"/&"===d)if(0===h)break;else h--;else"$"!==d&&"$?"!==d&&"$~"!==d&&"$!"!==d&&"&"!==d||h++}d=c.nextSibling;f.removeChild(c);c=d}while(c);for(;e.firstChild;)f.insertBefore(e.firstChild,c);g.data="$";g._reactRetry&&requestAnimationFrame(g._reactRetry)}}a.length=0}; $RC=function(a,b){if(b=document.getElementById(b))(a=document.getElementById(a))?(a.previousSibling.data="$~",$RB.push(a,b),2===$RB.length&&("number"!==typeof $RT?requestAnimationFrame($RV.bind(null,$RB)):(a=performance.now(),setTimeout($RV.bind(null,$RB),2300>a&&2E3<a?2300-a:$RT+300-a)))):b.parentNode.removeChild(b)};$RC("B:1","S:1")</script><div hidden id="S:3"></div><script>$RC("B:3","S:3")</script><div hidden id="S:0"></div><script>$RC("B:0","S:0")</script></body></html>