0

While converting png using html2canvas and later on I will draw that image on canvas. And I am using multiple font in html. But while converting font is not apply. So it looks different font

  function getCanvas() {
       form.width(myPageSize).css('max-width', 'none');
       return html2canvas(form, {
           useCORS: true,
           imageTimeout: 2000,
           removeContainer: true
       });
   }
vrintle
  • 5,501
  • 2
  • 16
  • 46
Nikhil Arote
  • 11
  • 1
  • 3
  • Hello! It is always a good idea to show your code along with your question so that we can see exactly whats going on. Or, you can always link a jsfiddle too! Thanks. – Chris Oct 04 '18 at 14:21
  • Please check above code form is element I am using Arial font directly not embedded using css – Nikhil Arote Oct 05 '18 at 05:34

2 Answers2

0

actually issue is with multiple font used in html so while converting image it fails for font. Now it is gets fixed and now only using single font

Nikhil Arote
  • 11
  • 1
  • 3
0
html2canvas(element, {
   onrendered: function (canvas) {
        var ctx = canvas.getContext('2d');
        ctx.webkitImageSmoothingEnabled = true;
        ctx.mozImageSmoothingEnabled = true;
        ctx.imageSmoothingEnabled = true;
        var img = canvas.toDataURL('image/png');
        console.log(img);
   }
})

I have tried this above code for my project, In this code 'element' is your html element for which you want to generate image.

Albert Einstein
  • 7,472
  • 8
  • 36
  • 71
PSabuwala
  • 155
  • 1
  • 9