0

I am trying to convert SVG to PDF which is working fine but it is returning me a blank PDF. How can i achieve my SVG in pdf?

var doc = new jsPDF('p', 'pt', 'letter');
    var test = $.get('/BarCodeSmallTag.svg', function (svgText) {
        var svgAsText = new XMLSerializer().serializeToString(svgText.documentElement);
        doc.addSVG(svgAsText, 20, 20, doc.internal.pageSize.width - 20 * 2)

        // Save the PDF
        doc.save('TestSVG.pdf');
    });
Awais
  • 37
  • 1
  • 9

1 Answers1

1

Check here to do that using canvg https://stackoverflow.com/a/35788928/2090459

Basically you need get base64 image to add into PDF(jsPDF). If we have canvas we can convert to base64 string using .toDataURL().

Check the demo here http://jsfiddle.net/Purushoth/hvs91vpq/

Community
  • 1
  • 1
Purushoth
  • 2,673
  • 3
  • 22
  • 36