jsPDF-AutoTable:特定行的字体样式“斜体”

问题描述 投票:0回答:1

我正在使用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中的文本不是斜体。我做错了什么?

javascript jspdf jspdf-autotable
1个回答
0
投票

你可以使用doc.setFontStyle('italic');

© www.soinside.com 2019 - 2024. All rights reserved.