I'm using jsPDF in my Typescript React project and I want to as an SVG to my PDF using jsPDF.
I use addSvgAsImage
like this:
let svg = this.ref.innerHTML
if (svg)
svg = svg.replace(/\r?\n|\r/g, '').trim()
pdf.addSvgAsImage(svg, 15, 45, 270, 130, 'SLOW')
and in my browser I got this error:
Uncaught (in promise) ReferenceError: canvg is not defined
at Object.et.addSvgAsImage (jspdf.min.js?e511:180)
...
It seems that I should include canvg
globally (https://github.com/MrRio/jsPDF/issues/2205), but I have no clue how I can do that.
Does anyone tried addSvgAsImage
in a React project or has an idea how I could solve this problem?