【发布时间】:2021-01-21 03:25:10
【问题描述】:
我正在使用 iText7 的 pdfHtml 插件将 HTML 表格转换为 PDF。但是我不能让它遵守定义的列宽。
我正在使用HtmlConverter.ConvertToDocument 将我的 HTML 转换为 PDF。
这是我的桌子:
table {
border-collapse: collapse;
}
table,
td,
th {
border: 1px solid black;
}
.gray-header {
background-color: lightgray;
}
<table style="table-layout: fixed; width: 700px;">
<thead>
<tr class="gray-header">
<th rowspan="2" style="width: 50px;">A</th>
<th rowspan="2" style="width: 250px;">B</th>
<th colspan="4" style="width: 400px;">COLSPAN</th>
</tr>
<tr class="gray-header">
<th>C</th>
<th>D</th>
<th>E</th>
<th>F</th>
</tr>
</thead>
<tbody>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
<td>D</td>
<td>F</td>
<td>G</td>
</tr>
</tbody>
</table>
这是 PDF 中的表格
A 列和 B 列的宽度相同。 B 应该是 A 的 5 倍。
【问题讨论】: