jsPDF
jsPDF copied to clipboard
Hooking svgElementToPdf into jsPDF as a plug-in.
With this change, code like this becomes possible:
var pdf = new jsPDF();
pdf.addSVG(svgData, 25, 50, options);
In comparison, without this change, something along the lines of the below is required:
var pdf = new jsPDF();
svgElementToPdf(svgData, pdf, { x_offset: 25, y_offset: 50 });
Note The method name "addSVG" conflicts with https://github.com/MrRio/jsPDF/blob/master/jspdf.plugin.sillysvgrenderer.js. This isn't a problem so long as we presume that the user will only use one SVG rendering plugin at a time.
I could take this a step further and wrap the entire body of svgToPdf.js code inside an anonymous function—as is commonly done with jsPDF plugins—if that would be desired.