我有一个div容器,其中包含一个span标签,其中包含svg标签元素并且必须将其转换为pdf。我尝试过使用html2canvas.js。我需要打印带边框的区域。请查看jsfiddle链接。一旦我转换为图像并使用jspdf库将转换为PDF格式 使用canvg库和html2canvas
后,SVg图像无法渲染https://jsfiddle.net/6pupxnca/5/
jQuery(document).on('click','#getpdf',function(){
//console.log("canvas");
html2canvas(jQuery('#view-front'),
{
background: '#fff',
allowTaint: true,
//console.log("adsfasdf");
onrendered: function (canvas) {
var a = document.createElement('a');
// toDataURL defaults to png, so we need to request a jpeg, then convert for file download.
a.href = canvas.toDataURL("image/png").replace("image/png", "image/octet-stream");
console.log(a.href);
a.download = 'somefilename.png';
a.click();
}
});
});