Javascript SvgToPdf抛出错误
我正在使用jsPddf.js在客户端生成pdf。 我的页面上有一个svg饼图,要在pdf上打印,我使用的是svgToPdf.js插件。 但我的浏览器控制台中出现以下错误: 未捕获类型错误:非法构造函数 导致错误的代码:var fillRGB=new RGBColor(fillColor) 以下是从svg生成pdf的代码:Javascript SvgToPdf抛出错误,javascript,jspdf,Javascript,Jspdf,我正在使用jsPddf.js在客户端生成pdf。 我的页面上有一个svg饼图,要在pdf上打印,我使用的是svgToPdf.js插件。 但我的浏览器控制台中出现以下错误: 未捕获类型错误:非法构造函数 导致错误的代码:var fillRGB=new RGBColor(fillColor) 以下是从svg生成pdf的代码: function createPdf() { var svg = $('#completed svg').get(0);
function createPdf() {
var svg = $('#completed svg').get(0);
var doc = new jsPDF();
doc.text(20, 20, 'This is the default font.');
doc.setFont("courier");
doc.text(20, 30, 'This is courier normal.');
doc.setFont("times");
doc.setFontType("italic");
doc.text(20, 40, 'This is times italic.');
doc.setFont("helvetica");
doc.setFontType("bold");
doc.text(20, 50, 'This is helvetica bold.');
doc.setFont("courier");
doc.setFontType("bolditalic");
doc.text(20, 60, 'This is courier bolditalic.');
svgElementToPdf(svg, doc, {
//cale: 72 / 96, // this is the ratio of px to pt units
removeInvalid: true // this removes elements that could not be translated to pdf from the source svg
});
doc.save('Test.pdf');
}
svgElementToPdf使用类RGBColor进行颜色解析,这可能是导致问题的原因。你可以从学校得到那门课 只需将javascript文件添加到您的javascript资产中,您就可以开始了 此外,要了解更多信息,请参阅