2015-12-22 87 views
1

我有3PDF中的不同表格,使用TCPDF創建,使用MultiCell來顯示它們。他們是上述海誓山盟及其nameswriteHTMLTCPDF Multicell overlapping

$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'); 

寫我positioningtables與設置它們的x & ycoordinates。該PDF看起來是這樣的,如果我add例如更多驅動程序: enter image description here

任何幫助,將不勝感激。

S.

回答

0

,你可以嘗試這樣的事情

$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'); 

希望可以幫助您