【问题标题】:PDF report generating in php在 php 中生成 PDF 报告
【发布时间】:2016-10-15 10:53:36
【问题描述】:

我有一个 php 文件,它从表格中生成客人评论的 pdf 报告。它显示得很好。但问题出在报告中,查看单元格内容显示在一行中。不打破它。请帮我在合适的点打破评论单元格中的线。

这是代码。

        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

【问题讨论】:

    标签: php pdf fpdf


    【解决方案1】:

    您需要使用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 [, 混合边框[, string align [, boolean fill]]])

    【讨论】:

    • 它给出了一个黑色的单元格
    • 尝试根据您的来源调整它。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-09-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多