yWorks / jsPDF

JavaScript PDF generation to work with SVG
MIT License
56 stars 23 forks source link

TypeError: m.saveGraphicsState is not a function #9

Closed shobeck closed 6 years ago

shobeck commented 6 years ago

I am new to this library. I have an SVG that I am trying to save as a PDF. SVG renders fine. But when I try to run the SVG2PDF - I get the following error:

ERROR TypeError: m.saveGraphicsState is not a function at it (svg2pdf.min.js:24)

With the following code: const svgElement = document.getElementById('svgelement'); const width = 300, height = 200;

// create a new jsPDF instance
const pdf = new JsPDF('l', 'pt', [width, height]);

// render the svg element
SVG2PDF(svgElement, pdf, {
  xOffset: 0,
  yOffset: 0,
  scale: 1
});

pdf.save('myPDF.pdf');

Any ideas?

Thanks, Sheila

shobeck commented 6 years ago

Solved: I was including the wrong library.

NOT THIS: import * as JsPDF from 'jsPdf';

THIS: *import as JsPDF from 'jsPdf-yworks';**