I'm trying to do a transformation about html to base64, but its not working. Can someone help me? On the first code is on a tag, this code try to make get the form values to transfer to the h3 id="testando" so I can change color, background and trying to put Font Awesome on my h3, later of this I'm trying to make my html convert to canvas and canvas convert to base64, but its not working
$(document).ready(function() {
$("#enviar").click(function() {
var unicode = $('#uunicode').val();
var fonte = "Font Awesome 5 Free";
var cor = $('#ccor').val();
var tamanho = $('#ctamanho').val();
$("#testando").css("color", cor);
$("#testando").css("font-size", tamanho);
html2canvas(document.getElementById("testando"), {
allowTaint: true,
useCORS: true
}).then(function(canvas) {
var anchorTag = document.createElement("a");
document.body.appendChild(anchorTag);
base64 = anchorTag.href = canvas.toDataURL();
alert(base64);
});
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.3.2/html2canvas.min.js" integrity="sha512-tVYBzEItJit9HXaWTPo8vveXlkK62LbA+wez9IgzjTmFNLMBO1BEYladBw2wnM3YURZSMUyhayPCoLtjGh84NQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<p>
<h3 id="testando"></h3>
</p>