我正在使用jsPDF-AutoTable插件来创建pdf。我有以下表结构:
<table id="TableTest" class="MainTable">
<tbody>
<tr>
<th>Vorgang</th>
<th></th>
<th style="width:80px; " >nicht<br/>relevant</th>
<th>in<br/>ordnung</th>
</tr>
<tr>
<td rowspan="2">1.</td>
<td>Durchsicht der Schaltgerätekombination</td>
<td rowspan="2">
</td>
<td rowspan="2">
</td>
</tr>
<tr>
<td>Inspection of the power switchgear and controlgear assemblies</td>
</tr>
</tbody>
文本为“检查电力开关设备和控制设备组件”的td应具有字体样式的“斜体”。因此,我尝试了以下代码:
doc.autoTable
({
head: [['Vorgang', ' ', 'Geprüft']],
body: allelements,
startY: 60,
font: 'times',
styles:
{
fontSize: 7,
minCellHeight: 3,
cellWidth: 'wrap'
},
willDrawCell: function(cell, data)
{
if(cell.row.cells[1].text[0] == "Inspection of the power switchgear and controlgear assemblies"){
cell.cell.styles.fontStyle = "italic";
console.log(cell);
}
},
headStyles:
{
fillColor: [55,55,55]
},
theme: "grid" //plain grid (oder freilassen)
});
doc.save('EFPruefprotokoll.pdf');font-style属性会改变,但pdf中的文本不是斜体。我做错了什么?
发布于 2019-02-25 21:40:53
您可以使用doc.setFontStyle('italic');
发布于 2021-11-28 05:14:25
在react中,内联样式起作用。style={{ fontStyle: 'italic' }}
https://stackoverflow.com/questions/54863673
复制相似问题