I'm trying to export a <svg>
element sitting in DOM to a PDF file, generated on client side.
I tried with different libraries, and pdfmake is so close to what I want. Any working example with this library or any other library would be helpful.
downloadPdf = function() {
//var docDefinition = { content: 'This is an sample PDF'};
var html = d3.select("svg")
.attr("version", 1.1)
.attr("xmlns", "http://www.w3.org/2000/svg")
.node().parentNode.innerHTML;
console.log(btoa(html));
var imgsrc = 'data:image/svg+xml;base64,'+btoa(html);
var docDefinition = {content: [{image: imgsrc}]}
pdfMake.createPdf(docDefinition).open('Sample.pdf');
}