Closed guidev224 closed 6 years ago
Duplicate of #50
@yGuy thanks for your quick answer, Even though I have added your jsPDF version I am still getting the same error. I have replaced the content of my local file by the content of your file content, but same error
Please provide minimal self-contained complete repro if you are sure that this is a bug. I don't currently think so.
@yGuy I din't really get what you mean by self-contained repo, but here what I have done: 1-I created a folder in to my desktop, 2-Created a svg2pdf.js file and copied the raw content of the svg2pdf.js file from your repository 3- Created jsPDF.js and copied the raw content of this file which is in the root directory of your jsPDF fork 4-Created an HTML file and included both of the aforementioned files 5- Created a script tag with the following content
const svgElement = document.getElementById('svg');
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
});
// get the data URI
const uri = pdf.output('datauristring');
// or simply safe the created pdf
pdf.save('myPDF.pdf');
which is the code you gave from your svf2pdf.js repository usage section.
I hope this will help understand the issue
If you use the jsPDF file from the "dist" folder (which is the one that contains all of the code) your sample works for me: https://github.com/yWorks/jsPDF/blob/master/dist/jspdf.min.js
And repro means "reproduction case": instructions that let others reproduce your findings.
Thanks @yGuy it works now
Hi, I am trying to use this library to export an svg element content as pdf but I am getting this error Uncaught TypeError: pt.saveGraphicsState is not a function even though I have added the jsPDF library
Any help?? Thanks in advance