web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Unanswered

sholud we use html2Canvas.js in crm 365 for create pdf from HTMl

(0) ShareShare
ReportReport
Posted on by 351

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

I have the same question (0)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Hamza H Profile Picture

Hamza H 142 Super User 2026 Season 1

#2
Nagaraju_Matta Profile Picture

Nagaraju_Matta 128

#3
11manish Profile Picture

11manish 121

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans