Si bien queremos imprimir la página HTML, la imagen no aparece en la vista previa de impresión, lo intenté con varias áreas pero no generé la salida. En este momento, en la vista previa de impresión, no se muestra la correcta. Es muy pedido a todos, por favor ayuda para este problema.
Aporte:
<?xml version="1.0" encoding="UTF-8"?> <pat id="Main_Window"> <title>Main Window</title> <body> <p>The main console screen includes nine panels or areas, which are shown and described below.</p> <p><image width="600" href="../MiVBC_Graphics1/MainWindow_CloudlinkChat.bmp" placement="break"/></p> <p>Content here</p> <p>Content here</p> <p>Content here</p> <p>Content here</p> </body> </pat>código Javascript:
function printIframe(url, height) { var heading_one = window.iframeHeight.heading var test = window.iframeHeight.maindivcontent console.log(test) console.log("fhghfjghdfjghfdg") var proxyIframe = document.createElement('iframe'); var body = document.getElementsByTagName('body')[0]; body.appendChild(proxyIframe); proxyIframe.style.width = '100%'; proxyIframe.style.height = '100%'; proxyIframe.style.display = 'none'; var contentWindow = proxyIframe.contentWindow; contentWindow.document.open(); var is_chrome = Boolean(contentWindow.chrome); contentWindow.document.write(test) contentWindow.document.write('<iframe onload="print();" frameborder="0" marginheight="0" marginwidth="0"></iframe>'); contentWindow.document.close(); if (is_chrome) { contentWindow.onload = function() { }; } else {contentWindow.document.write('<iframe onload="print();" frameborder="0" marginheight="0" marginwidth="0"></iframe>'); contentWindow.document.close(); }return true;}¿Aún te aparece fuera del modo de impresión? Porque cuando pruebo tu código no lo hace. Sin embargo, funciona cuando cambia el img href a src :
<p><image width="600" src="../MiVBC_Graphics1/MainWindow_CloudlinkChat.bmp" placement="break"/></p>Debe establecer un tiempo de espera para que el navegador tenga tiempo de procesar las imágenes. Prueba esto:
setTimeout(function() { contentWindow.print(); contentWindow.close(); }, 250);Y también necesita usar src en lugar de href