jsPDF icon indicating copy to clipboard operation
jsPDF copied to clipboard

Hooking svgElementToPdf into jsPDF as a plug-in.

Open bgribaudo opened this issue 10 years ago • 1 comments

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.

bgribaudo avatar Mar 05 '14 19:03 bgribaudo

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.

bgribaudo avatar Mar 17 '14 16:03 bgribaudo