0

How can I send a generated image to the (physical) printer from javascript in IE11?

The print command doesn't work. On right click - the "Save As" & "Print Target" are greyed out, but the "Print Picture" is available. Can I invoke "Print Picture" from javascript?

    var data = canvas.toDataURL('image/png');
    var image = new Image();
    image.src = data;
    var mywindow = window.open('', 'my div', 'height=400,width=600');
    mywindow.document.write('<html><head><title>Title</title>');
    mywindow.document.write('</head><body >');
    mywindow.document.write('<img src="' + data + '" />');
    mywindow.document.write('</body></html>');
    mywindow.print();
patrick
  • 16,091
  • 29
  • 100
  • 164
  • I don't believe you can directly with JS. You will need to call window.print() to bring up the print dialog and then you can print. You may want to use your server side language to print. – scrappedcola Sep 18 '15 at 14:43
  • 1
    possible duplicate of [Using javascript to print images](http://stackoverflow.com/questions/2909033/using-javascript-to-print-images) – scrappedcola Sep 18 '15 at 14:43

1 Answers1

0

You can't send anything to a printer automatically through JavaScript.

All you can do is use window.print() to bring up the print dialog.

Dave
  • 10,748
  • 3
  • 43
  • 54