I'm working on a web based graph application which connects different nodes via lines. To do so the connection lines are created by the library Leader-Lines. These connections are svg
elements, which consist out of different elements as masks, markers, rectangles, etc.
(they consist out of many lines of code so I outsourced the code into this JSFiddle)
In case the user finishes the graph he should be able to export the graph as an image. My plan was to create any image format from the html elements of the graph and then pass the image as a base64
string to the back-end to process it further.
I tried the following libraries to achieve this:
For html2canvas this is how I used the library:
html2canvas(document.querySelector("#myGraphContainerDiv"),
{ allowTaint: true }).then(canvas => {
var graphAsbase64 = canvas.toDataURL("image/png");
//Some ajax call to send the string to the backend
});
The problem: None of them was able to convert the svg
connection.
My next step was to try to convert the SVG to a canvas
and then try to convert the graph. This method was suggested in many SO posts. For this I used the library canvg but this didn't work either. For this I used the code from this answer.
Another problem I faced with this method was that with a big number of connections the process took longer and longer (over 1 minute with 8 connections).
The question: Is there a way to achieve the conversion of these connections or is this simply not possible at the moment?