Closed milicev closed 7 years ago
Problem solved!
function getESCPImageString(url, callback) {
img = new Image();
img.onload = function () {
// Create an empty canvas element
var canvas = document.createElement('canvas');
canvas.width = this.width;
canvas.height = this.height;
// Copy the image contents to the canvas
var ctx = canvas.getContext("2d");
ctx.drawImage(this, 0, 0);
// get image slices and append commands
var bytedata = esc_init + esc_a_c + getESCPImageSlices(ctx, canvas) + font_reset;
//alert(bytedata);
callback(bytedata);
};
img.src = url;
}
Instead img use this and no more overriding. For example: change previously canvas.width = img.width into canvas.width = this.width
Is there a way to print more than one image without override by last one?