在PHP

时间:2016-10-15 10:53:37

标签: php pdf fpdf

我有一个php文件,可以从表中生成客人评论的pdf报告。它表现得很好。但问题出在报告中,评论单元格内容显示在一行中。没有打破它。请帮助我在适当的时间点在评论单元格中划线。

enter image description here

以下是代码。     

        include("connect.php");

        $SQL = "SELECT * FROM reviews  ";
        $run=mysql_query($SQL,$con) or die ("SQL error");


    //---------------------pdf creation-------------------------------------------
require("fpdf/fpdf.php");
$pdf=new FPDF();
$pdf->AddPage();
$pdf->SetFont("Arial","B",10);
$pdf->Cell(190,10,"Guest reviews report",1,1,'C');
$pdf->SetFont("Arial","B",10);
$pdf->Cell(20,10,"Booking ID",1,0,'C');
$pdf->Cell(40,10,"Guest name",1,0,'C');
$pdf->Cell(50,10,"email",1,0,'C');
$pdf->Cell(60,10,"Review",1,0,'C');
$pdf->Cell(20,10,"Rate",1,1,'C');

while($row = mysql_fetch_array($run))
{

$pdf->SetFont("Arial","B",10);

        $pdf->Cell(20,10,$row['bookingid'],1,0);
        $pdf->Cell(40,10,$row['name'],1,0);
        $pdf->Cell(50,10,$row['email'],1,0);
        $pdf->Cell(60,10,$row['review'],1,0);
        $pdf->Cell(20,10,$row['rating'],1,1);       

}

$pdf->Output(); 

?>

我附上了报告的截图。 screenshot

1 个答案:

答案 0 :(得分:0)

您需要使用 MultiCell 。这是示例

$pdf->MultiCell(55, 5, $row['review'], 1, 'L', 1, 0, '', '', true);

以下是 tcpdf 的示例:https://tcpdf.org/examples/example_005/

有关MultiCell的文档:http://www.fpdf.org/en/doc/multicell.htm

注意:55是宽度,5是高度。在您的情况下,它们将是6010

  

MultiCell(float w,float h,string txt [,mixed border [,string align [,boolean fill]]])