0

html2canvas and jdpdf is ignoring the svg images when i download

    document.getElementById("download")
.addEventListener("click", () => {


  HTMLCanvasElement.prototype.getContext = function(origFn) {
    return function(type, attribs) {
      attribs = attribs || {};
      attribs.preserveDrawingBuffer = true;
      return origFn.call(this, type, attribs);
    };
  }(HTMLCanvasElement.prototype.getContext);
    

    const mapDownload = this.document.getElementById("mapDownload");
    console.log(window);
    var opt = {
        margin: 1,
        filename: 'myfile.pdf',
        image: { type: 'jpeg', quality: 0.98 },
        html2canvas: { scale: 2, useCORS: true, },
        jsPDF: { unit: 'in', format: 'letter', orientation: 'landscape' }
    };
    html2pdf().from(mapDownload).set(opt).save();
})

Above is the snippet. I am i missing anything here to make that work ?

Webpage with map marker Webpage with map marker

PDF downloaded enter image description here

  • May be this is your answer https://stackoverflow.com/questions/69493988/error-loading-svg-data-with-html2canvas-and-jspdf – Lalit Kumar Mar 28 '23 at 08:09
  • Answer seems unrelated to the question, but [this answer](https://stackoverflow.com/a/75852807/2181514) is that they had to convert svg's to png's first. – freedomn-m Mar 28 '23 at 09:17

0 Answers0