您可能遇到的是文本行的实际高度.在内部,TCPDF使用单元格高度比来控制渲染的线高.如果您的TD具有单行文本,则可以使用的最小值是行的总高度.所以td单元的最小尺寸是fontsize * cellheightratio任何被禁止的cellpadding
cellpadding可以来自cellpadding属性,因此我为此示例将其设置为0.我相信在编写HTML之前,至少还可以使用setCellPaddings设置一些填充维度.
您可以使用行高CSS声明来设置单元格高度比,以使行更小. (当然,您也可以减小字体大小.)
//For demonstration purposes, set line-height to be double the font size.
//You probably DON'T want to include this line unless you need really spaced
//out lines.
$this->setCellHeightRatio(2);
//Note that TCPDF will display whitespace from the beginning and ending
//of TD cells, at least as of version 5.9.206, so I removed it.
$html = <<
Row 1, Cell 1 | Row 1, Cell 2 |
Row 2, Cell 1 | Row 2, Cell 2 |
Row 3, Cell 1 | Row 3, Cell 2 |
Row 4, Cell 1 | Row 4, Cell 2 |
EOD;
$this->writeHTMLCell($w=0, $h=0, $x='', $y='', $html, $border=0, $ln=1, $fill=0, $reseth=true, $align='', $autopadding=true);
我的5.9.206安装上面的代码产生了这个:
这适用于第1行很大,是字体大小的两倍.第2行将行高设置为字体大小的100%.第3行是80%.第4行有50%.
*请注意,如果你的文字包装,它会在非常低的线高处看起来很糟糕.