27
rated 0 times
[
29]
[
2]
/ answers: 1 / hits: 20986
/ 11 Years ago, mon, december 16, 2013, 12:00:00
I want to print image with javascript.
So I used this code to open image in new window and print:
win = window.open(img.src,_blank);
win.onload = function() { win.print(); }
This works fine with the default image file:
<img id=image1 src=myimage.jpg>
But when i replace the default image with image data read from disk:
var fileElem = document.getElementById(fileElem).files[0];
var reader = new FileReader();
reader.onload = function(event) {
img.src = event.target.result;
};
reader.readAsDataURL(fileElem);
And then open new window & print - the image apears fine in the new window, but no print operation is done.
How to make the win.print() to work?
More From » image