I have fixed the issue. I was trying html2canvas and changed it to html2canvas-pro and this can make the function work without a problem.