从php生成PDF

时间:2018-09-06 02:11:05

标签: php html pdf fpdf

使用FPDF生成PDF文件时出现问题,这是我的代码

foreach($result as $row)
{
    $pdf->Ln(); 
    $pdf->Image("../img/ss/".$row['nama_foto'],10,30,-150);
    $pdf->Cell(5,150,$row['subject_ticket'],0,0,'L');

    $pdf->SetFont('Times','',9);
    $pdf->Cell(1,165,"Category : ".$row['kategori'],0,0,'L');
    $pdf->Cell(1,175,"File Uploaded : ".$row['nama_file'],0,0,'L');
    $pdf->Cell(1,185,"Messages : ".$row['isi_ticket'],0,0,'L');

}

这是屏幕截图 enter image description here

我想为所有单元格设置“左对齐”,但结果像这样卡住。

1 个答案:

答案 0 :(得分:2)

您应按以下方式使用setX方法设置单元格的X位置

    $pdf->SetFont('Times','',9);
    $pdf->setX(0);
    $pdf->Cell(1,165,"Category : kategor",0,0,'L');
    $pdf->setX(0);
    $pdf->Cell(1,175,"File Uploaded : nama_file",0,0,'L');
    $pdf->setX(0);
    $pdf->Cell(1,185,"Messages : isi_ticket",0,0,'L');