我尝试用html2canvas转换Base64中的图形。我的代码组件.html。
<div *ngIf="sem_chart" style="max-width: 100vw; padding-bottom: 20px; margin-bottom: 50px; background: white !important" id="kilos_acreditados_sem">
<h4>Kilos acreditados semana: {{semana_elegida}}</h4>
<ngx-charts-bar-vertical-2d style="fill: white !important"
[view]="view_sem_year"
[scheme]="colorSchemeSemYear"
[results]="multi_sem_year"
[gradient]="gradient"
[xAxis]="showXAxis"
[yAxis]="showYAxis"
[legend]="showLegend"
[legendPosition]="legendPosition"
[groupPadding]="2"
[yAxisTickFormatting]="yAxisFormating"
[legendTitle]="legendTitle"
>
</ngx-charts-bar-vertical-2d>
</div>
组件技术
html2canvas(document.getElementById("kilos_acreditados_sem"), { scale: 0.8, backgroundColor: '#ffffff' }).then(canvas => {
canvas.style.background = '#ffffff';
canvas.fillStyle = '#ffffff';
var data = canvas.toDataURL('image/png');
this.imgKilosAcreditados = data;
let img = canvas.toDataURL("image/jpeg", 1.0);
let imgElement = document.createElement("img");
imgElement.src=img
console.log("img = ", img)
// console.log('this.imgKilosAcreditados', this.imgKilosAcreditados);
});
}, 3000);
我试着捕捉这个(那个)[1]:https://i.stack.imgur.com/hqt8j.png 但结果是[2]:https://i.stack.imgur.com/fd8d8.png 我认为(或猜测)没有捕获属性填充,但我知道如何继续修复此问题。这张图片我需要显示pdfmake。对不起,我的英语不好。
暂无答案!
目前还没有任何答案,快来回答吧!