我正在使用angularjs创建一个项目。将html和svg转换为pdf时遇到问题。我正在使用插件:
简单的html转换为pdf,但svg不转换为pdf。
以下是我的示例代码,仅适用于html:
var html = document.getElementById('container_div');
html2canvas(html, {
useCORS: true,
allowTaint: true,
letterRendering: true,
onrendered: function (canvas) {
var data = canvas.toDataURL();
var docDefinition = {
content: [{
image: data,
width: 510,
}]
};
pdfMake.createPdf(docDefinition).download('price-calculation-' + $scope.getDateTimeFormat("YYYY-MM-DD-hh:mm:ss") + '.pdf');
$("#price-pdf-content").hide()
$('#export-pricing-model').modal('hide');
}
});
这是html:
<div class="row" id="container_div">
here are some divs which is converted to pdf
-------
----------
<svg id="svg_0" width="262" height="33" style="z-index:201;position:absolute;left:209px;top:89px" source-endpoint="b0668836-0ffb-ac83-fed3-e6c0e7b708df" destination-endpoint="83669f6e-6d12-aa90-717d-1c5e1a509809"><line id="line_0" class="line" x1="252" y1="23" x2="10" y2="10" stroke="#99ca3c" stroke-width="3" linkuuid="2c03ba9a-4dbe-e4b9-51ac-8a4038012189"></line></svg>// this svg is not converted
</div>