When searching for the answer to this question, I found a small open source library that does the trick: SVG-to-PDFKit .
If it is not convenient to implement your own interface, this one is quite easy to use (sample code from Readme):
PDFDocument.prototype.addSVG = function(svg, x, y, options) { return SVGtoPDF(this, svg, x, y, options), this; }; doc.addSVG(svg, x, y, options);
The parameters are as follows:
doc [PDFDocument] = PDF document created using PDFKit
svg [SVGElement or string] = SVG object or XML code
x, y [number] = position to add SVG to
Check out the demo here .
valentin
source share