是否可以使用 TCPDF 将 HTML 表格呈现为 PDF 并缩放它以适合页面?我的表中有很多列。是否可以缩小或缩小它以使其适合?
最佳答案
TCPPDF 允许您编写 HTML。这样,您的表结构就无关紧要了。
例子:
$tbl = <<<EOD
<table border="1">
<tr>
<th rowspan="3">Left column</th>
<th colspan="5">Heading Column Span 5</th>
<th colspan="9">Heading Column Span 9</th>
</tr>
<tr>
<th rowspan="2">Rowspan 2<br />This is some text that fills the table cell.</th>
<th colspan="2">span 2</th>
<th colspan="2">span 2</th>
<th rowspan="2">2 rows</th>
<th colspan="8">Colspan 8</th>
</tr>
<tr>
<th>1a</th>
<th>2a</th>
<th>1b</th>
<th>2b</th>
<th>1</th>
<th>2</th>
<th>3</th>
<th>4</th>
<th>5</th>
<th>6</th>
<th>7</th>
<th>8</th>
</tr>
</table>
EOD;
$pdf->writeHTML($tbl, true, false, false, false, '');
关于php - 在 TCPDF 中缩放 HTML 表格以适应 PDF 页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13621363/