Does not print image V2018

Does not print image.
$(’#div1’).print();
It was working normal on V2.
<div id='div1'><img src = 'logo.png' height = '100' width = '100' /></div>

Have you checked for any error in the Developer Tools console?

I found the solution =)

Html:
< div id=“printableArea”>
< h1>Print me
< /div>
< input type=“button” onclick=“printDiv(‘printableArea’)” value=“print a div!” />

JavaScript:
function printDiv(divName) {
var printContents = document.getElementById(divName).innerHTML;
var originalContents = document.body.innerHTML;

document.body.innerHTML = printContents;

window.print();

document.body.innerHTML = originalContents;
}

Summary

What happens is that the image is simply not printed.
I have no Developer Tools console errors.


In the CHROME it works normal, and it functions in v2.

Things are getting complicated!
As I’m going to buy a maintenance or upgrade >
If I only have errors?

The code used for printing:

// Create a jquery plugin that prints the given element.
jQuery.fn.print = function(){
// NOTE: We are trimming the jQuery collection down to the
// first element in the collection.
// collection (as defined by THIS), contains only one
// printable element.

// Create a random name for the print frame.
var strFrameName = ("printer");

// Create an iFrame with the new name.
var jFrame = $( "<iframe name='" + strFrameName + "'>" );

// Hide the frame (sort of) and attach to the body.
jFrame
.css( "width", "1px" )
.css( "height", "1px" )
.css( "position", "absolute" )
.css( "left", "-9999px" )
.appendTo( $( "body:first" ) )
;

// Get a FRAMES reference to the new frame.
var objFrame = window.frames[strFrameName];

// Get a reference to the DOM in the new frame.
var objDoc = objFrame.document;

// Grab all the style tags and copy to the new
// document so that we capture look and feel of
// the current document.

// Create a temp document DIV to hold the style tags.
// This is the only way I could find to get the style
// tags into IE.
var jStyleDiv = $( "<div>" ).append(
$( "style" ).clone()
);

// Write the HTML for the document. In this, we will
// write out the HTML of the current element.
objDoc.open();
objDoc.write( "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">" );
objDoc.write( "<html>" );
objDoc.write( "<body>" );
objDoc.write( "<head>" );
objDoc.write( "<title>" );
objDoc.write( document.title );
objDoc.write( "</title>" );
objDoc.write( jStyleDiv.html() );
objDoc.write( "</head>" );
objDoc.write( this.html() );
objDoc.write( "</body>" );
objDoc.write( "</html>" );
objDoc.close();

// Print the document.
objFrame.focus();
objFrame.print();

// Have the frame remove itself in about a minute so that
// we don't build up too many of these frames.
setTimeout(
function(){
jFrame.remove();
},
(60 * 1000));}

var goprint= function(){
$('#divid').print();
}//function      

Can you understand me?
Do you use CEF that is the same as CHROME and why do we have so many errors in the program?

I’m hoping for corrections.
Projects stopped = (

Thank you for your attention!!!

If I find a solution, I come here to post to help friends.

CEF and Chrome share the same original code, but they are different products. And you have different versions. Currently, CEF is based on Chromium 63. Which version of Chrome are you using?
Moreover, CEF is constantly being improved. Of course, it has also bugs since it is a complex project.

1 Like

I’m always using the newer version(Chrome Versão 64.0.3282.186.).
I’m sorry, I thought it was the same.
I understand, every doubt I have when I can solve it, I leave the solution to my friends.

I do not know if it would be possible, we have a print box like our chrome would be very good.
Using the print();

Once they implement Print Preview in CEF, we’ll be able to offer a similar box. But’s it’s not done yet.

1 Like