Codeigniter 3 中的单元/多单元 fpdf 换行

问题描述 投票:0回答:1

请帮忙,我正在 CodeIgniter 中使用 FPDF 创建发票,当我使用 CELL 时遇到问题,当文本超出单元格时,文本将越界。

当我使用MultiCell时,外观会改变。

如何解决,当“FULL NAME”和“COURSE NAME”超过列长度时会自动换行,其他列跟随“full name”和“course name”的列高

error_reporting(0); // AGAR ERROR MASALAH VERSI PHP TIDAK MUNCUL
        $pdf = new FPDF('p','mm', 'A4');
        $pdf->AddPage();
        // $pdf->Image($background, 0, 0, 210);
        // setting jenis font dan posisi
        
        $pdf->SetFont('Arial','B',15).$pdf->SetTextColor(8, 182, 201);
        $pdf->Cell(0,60,'',0,1);
        $pdf->Cell(0,5,'Invoice',0,1,'C');
        // ATTENTION
        $pdf->SetFont('Arial','',8);
        $pdf->Cell(150,5,'Attention To:',0,0,'');
        $pdf->Cell(50,5,'Invoice No: '.$invoice,0,1,'');        
        $pdf->Cell(150,5,$uni['pic_uni'],0,0,'');
        $pdf->Cell(50,5,'Date: '.date('d F Y', strtotime($data['date_created'])),0,1,'');
        $pdf->Cell(80,5,$uni['email_uni'],0,1,'');
        $pdf->Cell(80,5,$uni['universitas'],0,1,'');
        $pdf->MultiCell(60,5,$uni['alamat_uni'],0,1,'');
        
        // TABLE HEADER
        $pdf->Cell(0,8,'',0,1);
        $pdf->SetFont('Arial','',8).$pdf->SetTextColor(0, 0, 0).$pdf->SetDrawColor(181, 181, 181);
        $pdf->Cell(23,8,'Passport No',1,0,'C');
        $pdf->Cell(40,8,'Full Name',1,0,'C');
        $pdf->Cell(45,8,'Course Name',1,0,'C');
        $pdf->Cell(22,8,'Intake',1,0,'C');
        $pdf->Cell(33,8,'Tuition Fee / Commission',1,0,'C');
        $pdf->Cell(8,8,'%',1,0,'C');
        $pdf->Cell(24,8,'Total Commission',1,0,'C');

        // TABLE BODY
        $pdf->Cell(10,8,'',0,1);
        $pdf->SetFont('Arial','',8).$pdf->SetTextColor(0, 0, 0).$pdf->SetDrawColor(181, 181, 181);
        foreach ($detail as $row) {
            $id_nomor_student = $row['id_nomor_student'];
            $course = $this->db->query("SELECT * FROM tb_student_universitas JOIN tb_universitas ON tb_student_universitas.universitas_tujuan = tb_universitas.code_uni WHERE id_nomor_student='$id_nomor_student' ")->result_array();

            $pdf->Cell(23,8,$row['nomor_passpor_student'],1,0,'C');
            $pdf->Cell(40,8,$row['nama_student'],1,0,'C');
            $pdf->Cell(45,8,$course[0]['universitas'],1,0,'C');
            $pdf->Cell(22,8,date('F Y', strtotime($row['intake'])),1,0,'C');
            $pdf->Cell(33,8,$row['tuition_fee_commission'],1,0,'C');
            $pdf->Cell(8,8,$row['persen'],1,0,'C');
            $pdf->Cell(24,8,$row['total_commission'],1,1,'L');
        }
php codeigniter fpdf
1个回答
0
投票

您可以像这样使用fpdf库的row函数

 foreach ($detail as $row) {


            $pdf->Row(array($row['Full Name'],$row['Course Name']));

        }
© www.soinside.com 2019 - 2024. All rights reserved.