【发布时间】:2015-02-26 16:58:03
【问题描述】:
我在使用 jspdf 将 svg 元素呈现为 pdf 时遇到问题。我正在使用插件https://github.com/CBiX/svgToPdf.js/ 来执行此操作。
下面是我的代码
// I recommend to keep the svg visible as a preview
var tmp = document.getElementById("chartContainer");
var svgDoc = tmp.getElementsByTagName("svg")[0];
var pdf = new jsPDF('p', 'pt', 'a4');
svgElementToPdf(svgDoc, pdf, {
scale: 72 / 96, // this is the ratio of px to pt units
removeInvalid: false // this removes elements that could not be translated to pdf from the source svg
});
pdf.output('datauri'); // use output() to get the jsPDF buffer
它正在生成空白 pdf。请帮忙
【问题讨论】:
-
svgToPdf 仅支持 g,line,rect,ellipse,circle,text 元素和一些属性。只需将其作为一个简单的演示来播放即可。
-
@Priyesh Tiwari : 我遇到了同样的问题 svg 到 pdf 的转换,你是怎么解决你的问题的?