0

I am having trouble adding image to pdf with jspdf for a while now.

Image is not showing at all, but console doesn't show any errors.

Here is my code, can anyone please tell me where is my mistake:

    var doc = new jsPDF('landscape');

    var img = new Image(),
    canvas = document.createElement("canvas"),
    ctx = canvas.getContext("2d");

    img.onload = function () {
      ctx.drawImage(img, 0, 0 )
      var imgData = canvas.toDataURL('image/jpeg','1.0');
      doc.setFontSize(12);
      img.src = '/story_content/external_files/Certifikat.jpg';
      doc.addImage(imgData, 'png','15','40','200','200');
     }

    img.src = '/story_content/external_files/Certifikat.jpg';
Dwight
  • 52
  • 1
  • 6

0 Answers0