【问题标题】:jsPDF-AutoTable : Font-style "italic" for a specific rowjsPDF-AutoTable:特定行的字体样式“斜体”
【发布时间】:2019-02-25 10:02:45
【问题描述】:

我正在使用 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>

带有“Inspection of the power switchgear and controlgear assembly”文本的 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');

字体样式属性发生变化,但 pdf 中的文本不是斜体。 我做错了什么?

【问题讨论】:

    标签: javascript jspdf jspdf-autotable


    【解决方案1】:

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

    【讨论】:

      【解决方案2】:

      在反应中,内联样式有效。 style={{ fontStyle: 'italic' }}

      【讨论】:

        猜你喜欢
        • 2016-10-06
        • 2010-12-13
        • 2019-05-13
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多