I'm trying to use html2canvas.js
(https://html2canvas.hertzen.com/) to take screenshots with JavaScript. However, I have a problem when the page contains SVG text elements.
As you can see on the screenshots below, the text element is duplicated (and only one of the copies keep the right font family).
Here is my code
HTML
<svg width="600" height="200" style="background-color:lightblue;">
<text transform="translate(100, 100)" style="font-size:60px; font-family: 'Oswald'">Hello world</text>
</svg>
<br/>
<button id="createCanvasButton">Create canvas !</button>
CSS
@import url(//fonts.googleapis.com/css?family=Oswald);
JS
$('#createCanvasButton').on('click', function() {
html2canvas(document.body).then(function(canvas) {
document.body.appendChild(canvas);
});
});
jsFiddle
https://jsfiddle.net/AndreLovichi/571t86u4/
Note
I've been looking for a similar issue, and I've found this one: SVG Text attribute is doubling - HTML2CANVAS.
However, the patch on NodeParser.prototype.getChildren
didn't work for me: the remaining text element had the wrong font family.
Thanks a lot!