html2canvas - error: Element is not attached to a Document
Пробую 2 функции - суть у них одна и работают они на html2canvas
function test() {
// Get the element.
var element = document.getElementById('container');
// Generate the PDF.
html2pdf().from(element).set({
margin: 1,
foreignObjectRendering: true,
filename: 'test.pdf',
html2canvas: { scale: 2 },
jsPDF: {orientation: 'portrait', unit: 'in', format: 'letter', compressPDF: true}
}).save();
}
$(function() {
$("#btnSave").click(function() {
html2canvas($("#container"), {
onrendered: function(canvas) {
theCanvas = canvas;
document.body.appendChild(canvas);
// Convert and download as image
Canvas2Image.saveAsPNG(canvas);
$("#img-out").append(canvas);
// Clean up
//document.body.removeChild(canvas);
}
});
});
});
Есть див который я хочу преобразовать.
<div id="container" style="width: 1000px; height: 500px; background-color: #1b5c72;">
<div onclick="doSomething(event, this); changeColor(event, this)" class="magnet" style="display: inline-block;">
<object class="123" style="pointer-events: none" width="200"
height="300"
type="image/svg+xml"
data="images/tiles/a4-vertical.svg">
</object>
</div>
<div style="background-color: red; width: 100px; height: 100px;"></div>
</div>
Конвертируется только большой и маленький див без содержимого .
html2canvas получается не может работать с <object>?
Или я что-то делаю не так?