我正在尝试使用jsPDF AutoTable的toHTML
功能来导入HTML表,但是这样做的时候它为null。据我所知,我正在遵循jsPDF示例使用的确切语法和结构。
这是表格HTML。在函数中,这顺利通过了:
<table id="statementDetailsTable">
<tbody id="statementDetailTable">
<tr class="flex-container-row" style="text-align: center;">
<th class="labelCell">Statement Detail</th>
<th class="labelCell">Statement Date: <span
id="statementDateB">8/28/2016</span></th>
<th class="labelCell">Account No: <span id="statementIdB">11453</span></th>
</tr>
<tr class="flex-container-row">
<td class="cell">Claim No.</td>
<td class="cell">Visit Date</td>
<td class="cell">Activity Dt</td>
<td class="cell">Description of Service</td>
<td class="cell">Charges</td>
<td class="cell">Payments</td>
<td class="cell">Balance</td>
</tr>
</tbody>
</table>
这是功能。如前所述,所有变量都可以正常工作,直到与autoTableHtmlToJson
所在的行为止。它只是显示为空。
function printStatement() {
const pdf = new jsPDF('p', 'px', 'letter');
pdf.setFontSize(12);
pdf.setTextColor('#000000');
let tableHtml = document.getElementById("statementDetailsTable");
let res = pdf.autoTableHtmlToJson(tableHtml); //res comes out null
pdf.autoTable(res.columns, res.data, {startY: 0});
iframe.src = pdf.output('bloburl');
pdf.autoPrint({variant: 'non-conform'});
}