TCPDF多单元重叠

时间:2015-12-22 11:55:31

标签: php html pdf tcpdf fpdf

3中有PDF个不同的表格,使用TCPDF创建,使用MultiCell来显示它们。它们位于彼此之上,nameswriteHTML

编写
$html = '<html>
<body>
<p style="line-height: 10%"><h3>CarhireInfo</h3>
</body>
</html>';

$pdf->writeHTML($html, true, false, true, false, '');
$pdf->MultiCell($w=0, $h=0, $cars, $border=0, $align='L', $fill=false, $ln=0, $x='70', $y='74', $reseth=true, $stretch=0, $ishtml=false, $autopadding=true, $maxh=0);
$pdf->MultiCell($w=0, $h=0, $drivers, $border=0, $align='L', $fill=false, $ln=0, $x='125', $y='70', $reseth=true, $stretch=0, $ishtml=false, $autopadding=true, $maxh=0);
$pdf->Ln(20);

$html = '<html>
<body>
<p style="line-height: 0"><h3>Manager/-in</h3>
</body>
</html>';
$pdf->writeHTML($html, true, false, true, false, '');
$pdf->MultiCell($w=0, $h=0, $manager, $border=0, $align='L', $fill=false, $ln=0, $x='125', $y='90', $reseth=true, $stretch=0, $ishtml=false, $autopadding=true, $maxh=0);
$pdf->Ln(20);

$html = '<html>
<body>
<p style="line-height: 0"><h3>Descriptions</h3>
</body>
</html>';
$pdf->writeHTML($html, true, false, true, false, '');
$start_y = $pdf->GetY();
$start_page = $pdf->getPage();
$pdf->MultiCell($w=0, $h=0, $descriptions, $border=0, $align='L', $fill=false, $ln=1, $x='', $y='', $reseth=true, $stretch=0, $ishtml=false, $autopadding=true, $maxh=0);

$pdf->lastPage();
$pdf->Output('CarhireInfo.pdf', 'D');

positioning tables设置了x&amp; y coordinatesPDF看起来像这样,如果我add更多的驱动程序,例如: enter image description here

任何帮助都将不胜感激。

S上。

1 个答案:

答案 0 :(得分:-1)

你可以尝试这样的事情

$html = '<html>
<body>
<p style="line-height: 10%"><h3>CarhireInfo</h3>
</body>
</html>';

$pdf->writeHTML($html, true, false, true, false, '');$startX1=$pdf->GetX();$startY1=$pdf->getY();
$pdf->MultiCell($w=0, $h=0, $cars, $border=0, $align='L', $fill=false, $ln=0, $x='70', $y='74', $reseth=true, $stretch=0, $ishtml=false, $autopadding=true, $maxh=0);$startX2=$pdf->GetX();$startY2=$pdf->getY();
$pdf->MultiCell($w=0, $h=0, $drivers, $border=0, $align='L', $fill=false, $ln=0, $x='125', $y='70', $reseth=true, $stretch=0, $ishtml=false, $autopadding=true, $maxh=0);$startX3=$pdf->GetX();$startY3=$pdf->getY();
//$pdf->Ln(20);

$html = '<html>
<body>
<p style="line-height: 0"><h3>Manager/-in</h3>
</body>
</html>';
if ($startY1>=$startY2 && $startY1>=$startY3){
  $pdf->setY($startY1);
}else if($startY2>=$startY3 && $startY2>=$startY1){
  $pdf->setY($startY2);
}else{
  $pdf->setY($startY3);
}
$pdf->writeHTML($html, true, false, true, false, '');$startX1=$pdf->GetX();$startY1=$pdf->getY();
$pdf->MultiCell($w=0, $h=0, $manager, $border=0, $align='L', $fill=false, $ln=0, $x='125', $y='90', $reseth=true, $stretch=0, $ishtml=false, $autopadding=true, $maxh=0);$startX2=$pdf->GetX();$startY2=$pdf->getY();
//$pdf->Ln(20);

$html = '<html>
<body>
<p style="line-height: 0"><h3>Descriptions</h3>
</body>
</html>';
if ($startY1>=$startY2){
  $pdf->setY($startY1);
}else{
  $pdf->setY($startY2);
}
$pdf->writeHTML($html, true, false, true, false, '');
$start_y = $pdf->GetY();
$start_page = $pdf->getPage();
$pdf->MultiCell($w=0, $h=0, $descriptions, $border=0, $align='L', $fill=false, $ln=1, $x='', $y='', $reseth=true, $stretch=0, $ishtml=false, $autopadding=true, $maxh=0);

$pdf->lastPage();
$pdf->Output('CarhireInfo.pdf', 'D');

希望能帮到你