我正在try 使用其URL从AWS S3存储桶添加一个图像,其数据格式如下:
[{
netValue: 13702.5,
prodCode: "UPP",
prodDesc: "Privacy Panel",
prodImg: "https://url/images/UPP02.png",
prodQty: 20,
unitPrice: 870
}]
其中,我的html文件中的表如下所示:
<table class="table table-hover table-responsive-xxl table-bordered" id="prodTable" #prodTable>
<thead>
<tr class="table-reflow">
<th>S. N</th>
<th>Product Code</th>
<th>Description</th>
<th>Image</th>
<th>Qty</th>
<th>Price</th>
<th>Amount</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let prod of prodDetailsArr; let i = index">
<td>{{ i+1 }}</td>
<td>{{ prod.prodCode }}</td>
<td>{{ prod.prodDesc }}</td>
<td><img [src]="prod.prodImg"></td>
<td>{{ prod.prodQty }}</td>
<td>{{ prod.unitPrice }}</td>
<td>{{ prod.netValue }}</td>
</tr>
</tbody>
</table>
由于PDF文件中显示的表没有图像,我try 使用下面的代码访问它,但得到了以下停止编译的错误,尽管sole.log(Td)给出了正确的img及其src:
autoTable(doc, {
html: '#prodTable',
startY: 200,
theme: 'plain',
tableLineColor: [0, 0, 0],
tableLineWidth: 0.5,
margin: {
left: 5,
right: 7
},
didDrawCell: function(data) {
if (data.column.index === 3 && data.cell.section === 'body') {
var td = data.cell.raw;
console.log(td)
var img = td.getElementsByTagName('img')[0];
var dim = data.cell.height - data.cell.padding('vertical');
doc.addImage(img.src, data.cell.x, data.cell.y, dim, dim);
}
}
})
类型‘HTMLTableCellElement|CellInput’上不存在属性‘getElementsByTagName’. 类型"字符串"上不存在属性""getElementsByTagName"".""
当我试图保存pdf时,我得到:
区域-evergreen.js:2981 CORS策略阻止了对位于‘https://url/images/UPP02.png’From Origin‘http://localhost:4200’的XMLHttpRequest的访问:请求的资源上不存在‘Access-Control-Allow-Origin’标头.
错误:addImage不支持‘UNKNOWN’类型的文件,请确保添加了支持‘UNKNOWN’的插件. 在对象P(jspdf.es.min.js:86:93253) 在push../node_modules/jspdf/dist/jspdf.es.min.js.e.addImage
我到底做错了什么?