Hello

I am get error from html2canvas.js when  I am create pdf from html.

Error:

new_html2canvas.min:20 Uncaught (in promise) Error: Element is not attached to a Document
    at new_html2canvas.min:20
    at new_html2canvas.min:20
    at Object.next (new_html2canvas.min:20)
    at new_html2canvas.min:20
    at new Promise (<anonymous>)
    at a (new_html2canvas.min:20)
    at Vs (new_html2canvas.min:20)
    at new_html2canvas.min:20
    at getCanvas (new_AccountBasicInformation?Data=AccountId%3d936B419F-9F4B-E111-BB8D-00155D03A715:350)
    at createPDF (new_AccountBasicInformation?Data=AccountId%3d936B419F-9F4B-E111-BB8D-00155D03A715:333)
(anonymous) @ new_html2canvas.min:20
(anonymous) @ new_html2canvas.min:20
(anonymous) @ new_html2canvas.min:20
(anonymous) @ new_html2canvas.min:20
a @ new_html2canvas.min:20
Vs @ new_html2canvas.min:20
(anonymous) @ new_html2canvas.min:20
getCanvas @ new_AccountBasicInformation?Data=AccountId%3d936B419F-9F4B-E111-BB8D-00155D03A715:350
createPDF @ new_AccountBasicInformation?Data=AccountId%3d936B419F-9F4B-E111-BB8D-00155D03A715:333
onclick @ new_AccountBasicInformation?Data=AccountId%3d936B419F-9F4B-E111-BB8D-00155D03A715:370
Promise.then (async)
createPDF @ new_AccountBasicInformation?Data=AccountId%3d936B419F-9F4B-E111-BB8D-00155D03A715:333
onclick @ new_AccountBasicInformation?Data=AccountId%3d936B419F-9F4B-E111-BB8D-00155D03A715:370

Code:

function createPDF(){
     
      var pdfName = filename+".pdf";
      getCanvas().then(function (canvas) { 
         var 
          img = canvas.toDataURL("image/png"), 
          doc = new jsPDF({ 
           unit: 'px', 
           format: 'a4' 
          }); 
         doc.addImage(img, 'PNG', 20, 20); 
         doc.save(pdfName); 
         form.width(cache_width);


     });
     }
     // create canvas object 
       function getCanvas() { 
        form.width((a4[0] * 1.33333) - 80).css('max-width', 'none'); 
        return html2canvas($('#root'), { 
         imageTimeout: 2000, 
         removeContainer: true 
        }); 
       } 

Thanks & Regards