从 php 生成 PDF

Generate PDF from php

我在使用 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');

}

这是截图

我想为所有单元格设置左对齐,但结果卡住了。

你应该使用如下的setX方法来设置Cell的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');