我正在尝试将我的多单元格和其他单元格的高度调整为多单元格的最高高度。
使用下面的代码,这就是我的pdf现在的样子。唯一的问题是我无法调整说明列以使其与子代码的最高MULTICELL对齐。 SUBCODE和DESCRIPTION均为MULTICELL,其余均为普通单元。
$h1 = $pdf->GetMultiCellHeight(85, 5, $r->subdesc, $border=null, $align='J');
$h2 = $pdf->GetMultiCellHeight(35, 5, $r->subcode, $border=null, $align='J');
$height = ($h1 > $h2) ? $h1 : $h2;
$pdf->Cell(20,$height,$r->section,1,0,'L');
$pdf->Cell(15,$height,$r->code,1,0,'L');
$subcode = ($r->wga == 1) ? '*'.$r->subcode : $r->subcode;
$x = $pdf->GetX();
$y = $pdf->GetY();
$pdf->MultiCell(35, 5, iconv("UTF-8", "ISO-8859-1", $r->subcode), 1);
$pdf->SetXY($x + 35, $y);
$x = $pdf->GetX();
$y = $pdf->GetY();
$pdf->MultiCell(85, 5, iconv("UTF-8", "ISO-8859-1", $r->subdesc), 1,'L', false);
$pdf->SetXY($x + 85, $y);
$pdf->Cell(10,$height,$r->units,1,0,'C');
$pdf->Cell(10,$height,$r->grade,1,0,'C');
$pdf->Cell(20,$height,$r->remark,1,0,'C');
$pdf->Ln();
答案 0 :(得分:0)
两种方法: 1.绘制带有底部边框(具有正确高度)的空单元格和没有底部边框的多单元格
$x = $pdf->GetX();
$y = $pdf->GetY();
$pdf->Cell(195, $height, "", 1, 0, 'B');
$pdf->SetXY($x, $y);
$pdf->Cell(20,$height,$section,1,0,'L');
$pdf->Cell(15,$height,$code,1,0,'L');
$subcode = ($wga == 1) ? '*'.$subcode : $subcode;
$x = $pdf->GetX();
$y = $pdf->GetY();
$pdf->MultiCell(35, 5, iconv("UTF-8", "ISO-8859-1", $subcode), 'L,T,R');
2。甚至是多单元行:
$height = ($h1 > $h2) ? $h1 : $h2;
$subcode = ($wga == 1) ? '*'.$subcode : $subcode; //have to be done here
if($h1<$height){
for($i=$h1; $i<=$height; $i++)
$subdesc .= "\n";
}elseif($h2<$height){
for($i=$h2; $i<=$height; $i++)
$subcode .= "\n";
}