FPDI ช่วยให้การสร้างเอกสาร PDF ด้วย PHP นั้นเป็นเรื่องง่ายๆ

ตัวอย่างโค้ด PHP สร้าง PDF ด้วย TCPDF + FPDI กับการกรอกข้อมูลลงในแบบฟอร์มที่กำหนด

        public function print_request_pdf($student_code= '') 
{
                $this->load->library('request/Form_preview_pdf');
$pdf = new FPDI('P', PDF_UNIT, 'A4', true, 'UTF-8', false);
$font = 'thsarabun';
$pdf->font = $font;
$pdf->SetCreator("");
$pdf->SetAuthor("");
$pdf->SetTitle("แบบฟอร์มขอผ่อนผัน");
$pdf->SetSubject("แบบฟอร์มขอผ่อนผัน");
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
$pdf->SetMargins(10, 10, 10);
$pdf->SetHeaderMargin(0);
$pdf->SetTopMargin(15);
$pdf->SetFooterMargin(0);
$pdf->SetFont($font, '', 16);
                $border = 1;//test
$file = "./assets/file_store/pdf/form_request_extension_time_payment.pdf";
if (file_exists($file)) {
$pageCount = $pdf->setSourceFile($file);
$pageId = $pdf->importPage(1);
$pdf->AddPage("P");
$pdf->useTemplate($pageId, 0);
$y = $pdf->GetY();
                        
                        $x = 120;
                        $date = '17 กุมภาพันธุ์ 2564';
$pdf->writeHTMLCell(20, 0, $x, $y, $date , $border, 1, 0, true, 'C', true);


                        $y = $y + 15;
                        $x = 20;
                        $name = 'PHP CI MANIA';
$pdf->writeHTMLCell(60, 0, $x, $y, $name, $border, 1, 0, true, 'C', true);


$pdf->Output('request_extension_time_payment_'.$student_code.'.pdf', 'I');

}
 }


วิดีโอการสร้างฟังก์ชั่นสำหรับพิมพ์ PDF
https://www.youtube.com/watch?v=WQaFPOI_BRA




PHP CI MANIA - PHP Code Generator 

โปรแกรมช่วยสร้างโค้ด "ลดเวลาการเขียนโปรแกรม"
ราคาสุดคุ้ม  
http://fastcoding.phpcodemania.com

ความคิดเห็น