1
I am trying to issue a subscription voucher on a page, and in it you have the option to save the voucher as image, on the voucher page DO NOT have the header with the company logo and the name of the signature, i want to add this to the image but without it appearing to my user,the code below and what I have and generates the image perfectly the way I want, I just need to add a header in the image with the logo and any writing in front.
function gerarImagem() {
html2canvas(document.getElementById('telaPrint')).then(function(canvas) {
var name = 'img-print';
let xhr = new XMLHttpRequest();
xhr.responseType = 'blob';
xhr.onload = function() {
let a = document.createElement('a');
a.href = window.URL.createObjectURL(xhr.response);
a.download = name + '.png';
a.style.display = 'none';
document.body.appendChild(a);
a.click();
a.remove()
};
xhr.open('GET', canvas.toDataURL("image/png", 1.0));
xhr.send();
});
}
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>34571073</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.4.1/html2canvas.min.js"></script>
</head>
<body>
<div id="telaPrint" style="background-color: #fff">
<pre>
dsadadadada
asdadadsada
adadada
adadadasdada
</pre>
</div>
<button onClick="gerarImagem()">img</button>
</body>
in case the above code does not work for Cdn has this codepen.
sorry for the inexperience here at stackoverflow editor