HTML画布
<div id="convert" *ngIf="!show">
value : {{name}}
<center>
<img src="../../assets/logokuptm.png" class="img-fluid" alt="Responsive image" style="width: 350px; height: 250px">
</center></div>
这是我的HTML,我希望将其转换为pdf,但我希望图像仅以PDF显示,而不显示在页面上。我已经尝试过ngIf,但是它将在页面上显示图像,并且我也已经尝试了可见,但是它无法捕获图像。那么如何使它仅显示在PDF上?
我的捕获屏幕
public captureScreen() {
const data = document.getElementById('convert');
html2canvas(data).then(canvas => {
const imgWidth = 208;
const pageHeight = 295;
const imgHeight = canvas.height * imgWidth / canvas.width;
const heightLeft = imgHeight;
const contentDataURL = canvas.toDataURL('image/png');
const pdf = new jspdf('p', 'mm', 'a4');
const position = 0;
pdf.addImage(contentDataURL, 'PNG', 0, position, imgWidth, imgHeight);
pdf.save('MYPdf.pdf');
this.show = true;
});
}