yWorks / svg2pdf.js

A javascript-only SVG to PDF conversion utility that runs in the browser. Brought to you by yWorks - the diagramming experts
MIT License
655 stars 101 forks source link

pt.saveGraphicsState is not a function #50

Closed tonyhayes closed 6 years ago

tonyhayes commented 6 years ago

I've just downloaded your repo and I using your example in a Vue/Webpack application. I'm getting this error ... Uncaught TypeError: pt.saveGraphicsState is not a function at e (svg2pdf.min.js?95fe:formatted:2203) at VueComponent.getPDF (Charts.vue?6ddd:125)

import * as JsPdf from 'jspdf';
import * as svg2pdf from 'svg2pdf.js';
      console.log('getPDF');
      // Get svg markup as string
      var svg = document.getElementById('svg-container');

      // create a new jsPDF instance
      const pdf = new JsPdf('l', 'pt', 'a4');

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

      // get the data URI
      // const uri = pdf.output('datauristring');

      // or simply safe the created pdf
      pdf.save('myPDF.pdf');
    },
yGuy commented 6 years ago

This normally indicates that you are not using our fork of jsPDF, but the original one (which doesn't have that function).

If you think this is a bug with our fork, please provide a way for us to reproduce the problem.

tonyhayes commented 6 years ago

yes, working now!