Search code examples
phpfpdftabular

How to make a table like this with fpdf using PHP?


How do you make a table like this with FPDF using PHP?

I can't seem to figure out how to do this with $this->Cell.

enter image description here


Solution

  • OK .. let's try. Just an example .. an idea. ok ?

    $pdf->SetFillColor(255,0,0);
    $pdf->SetTextColor(255);
    $pdf->SetDrawColor(128,0,0);
    $pdf->SetLineWidth(.3);
    
    // Title row
    $pdf->SetFont('', 'B');
    $pdf->Cell(100, 8, "LEARNING POTENTIAL", 1, 0, 'L', true);
    $pdf->SetFont('', '');
    $pdf->Cell(20, 8, "Score", 1, 0, 'C', true);
    $pdf->Cell(20, 8, "Results", 1, 0, 'C', true);
    $pdf->>Ln();
    
    // Data rows
    
    // (loop) foreach($data as $row) {
    
        $pdf->SetFont('', 'B');
        $pdf->Cell(100, 8, "Reasoning", "LTR", 0, 'L');
        $pdf->Cell(20, 8, "", "LTR");
        $pdf->Cell(20, 8, "", "LTR");
        $pdf->>Ln();
    
        $pdf->SetFont('', 'B');
        $pdf->Cell(100, 8, "The ability to interpret information and", "LR", 0, 'L');
        $pdf->SetFont('', '');
        $pdf->Cell(20, 8, "6", "LR");
        $pdf->Cell(20, 8, "Effective", "LR");
        $pdf->>Ln();
    
        $pdf->SetFont('', 'B');
        $pdf->Cell(100, 8, "drawing accurate conclusions", "LBR", 0, 'L');
        $pdf->Cell(20, 8, "", "LBR");
        $pdf->Cell(20, 8, "", "LBR");
        $pdf->>Ln();
    
    // (end loop)
    

    I divided each data row in 3 rows.