why?
Some error here... looks like absolute div not in body cause this (but should).
Little demo attached:
errorExample.zip
it still has problem. i replaced the new version but because of "onrendered" function i have the same problem,however i have followed this address: https://github.com/niklasvh/html2canvas/blob/master/.github/ISSUE_TEMPLATE.md
I had this same error and it looks like its just a load order issue. Move the div element (whatever you're targeting) above the script tag call (where you call the html2canvas() function, not where you load the script itself) and it resolves the bug.
give us sample
i have this same error now and how to fixed it , i only find the problem in Android phone
This was my code and I was getting this error.
function pdfprint(selector,export_filename,quality = 1) {
const filename = export_filename+'.pdf';
html2canvas(document.querySelector(selector),
{scale: quality}
).then(canvas => {
let pdf = new jsPDF('p', 'mm', 'a4');
pdf.addImage(canvas.toDataURL('image/png'), 'PNG', 0, 0, 211, 298);
pdf.save(filename);
});
}
For me, the issue went away when i stopped used a class as a query selector - eg: ".kt-report" and used and id instead, eg: "#report-wrapper"
let moveLeft = () => {
$('#container div').last().fadeOut(1000, () => {
$(this).insertBefore($('#container div').first()).show()
})
}
this is my code and I got the same error. how do i fix it?
I had the same problem.
I resolved it by checking the element id (I put a wrong one).
Finally found an issue to this problem by changing this line
--> var canvas = this.canvas.ownerDocument.createElement('canvas');
to
--> var canvas = this.canvas.ownerDocument?this.canvas.ownerDocument.createElement('canvas'):document.createElement('canvas');
in the source code at line 6587 of html2canvas.js
I used id selector instead of class for element to print in pdf.
I had the same problem using an id: I fixed it by including '#' before the id
Most helpful comment
Finally found an issue to this problem by changing this line
-->
var canvas = this.canvas.ownerDocument.createElement('canvas');
to
-->
var canvas = this.canvas.ownerDocument?this.canvas.ownerDocument.createElement('canvas'):document.createElement('canvas');
in the source code at line 6587 of html2canvas.js
I used id selector instead of class for element to print in pdf.