PHP while 循环中的 fpdf - 我想拆分成多个 pdf
PHP fpdf in while loop - I want to split into multiple pdf
我在下面有这段代码。如何根据 while 循环的数据生成多个 PDF?现在它只生成一个 PDF。例如,如果有 5 名员工,它还应该生成 5 个 PDF,每个 PDF 都有唯一的员工 name.Thanks Much.
<?php session_start() ; ?>
<?php include "../db_connection301.php" ; ?>
<?php include "../db_connection302.php" ; ?>
<?php include "../db_connection303.php" ; ?>
<?php include "../db_connection304.php" ; ?>
<?php include "../db_connection305.php" ; ?>
<?php
require_once('../../bus_partners/fpdf/fpdf/fpdf.php');
require_once('../../bus_partners/fpdf/fpdi/fpdi.php');
$pdf = new FPDI();
$query_data = "SELECT * FROM alphalist_compen_2019";
$result_alphalist = mysqli_query($connection303, $query_data ) ;
while ($row_alphalist = mysqli_fetch_array($result_alphalist)) {
$ee_numbers = $row_alphalist['EE_NUMBER'] ;
$last_name = $row_alphalist['LAST_NAME'] ;
$first_name = $row_alphalist['FIRST_NAME'] ;
$employee_name = $first_name." ".$last_name ;
$pageCount = $pdf->setSourceFile('C:/wamp64/www/dbsmypay.com/bus_partners/BIR-forms/2316-new.pdf') ;
$tplIdx = $pdf->importPage(1, '/MediaBox') ;
$pdf->SetAutoPageBreak(false) ;
$pdf->addPage('P', 'Legal') ; // SETTING THE PAPER SIZE OF THE PDF
$pdf->useTemplate($tplIdx, 8, 12, 200, 320) ; // SETTING THE MARGIN LEFT TOP RIGHT BOTTOM
$pdf->SetFont('Arial') ;
$pdf->SetFontSize(10) ;
$pdf->SetTextColor(12, 12, 12) ;
$pdf->SetXY(46, 283) ;
$pdf->Write(0, $employee_name) ;
}
$file_location = "C:/wamp64/www/dbsmypay.com/per-day/bir-2316/2019/".$ee_numbers.".pdf" ;
$pdf->Output($file_location,'F') ;
将您的 $pdf = new FPDI();
和 $pdf->Output($file_location,'F') ;
放入 while 循环中,如下所示:
<?php session_start() ; ?>
<?php include "../db_connection301.php" ; ?>
<?php include "../db_connection302.php" ; ?>
<?php include "../db_connection303.php" ; ?>
<?php include "../db_connection304.php" ; ?>
<?php include "../db_connection305.php" ; ?>
<?php
require_once('../../bus_partners/fpdf/fpdf/fpdf.php');
require_once('../../bus_partners/fpdf/fpdi/fpdi.php');
$query_data = "SELECT * FROM alphalist_compen_2019";
$result_alphalist = mysqli_query($connection303, $query_data ) ;
while ($row_alphalist = mysqli_fetch_array($result_alphalist)) {
$pdf = new FPDI();
$ee_numbers = $row_alphalist['EE_NUMBER'] ;
$last_name = $row_alphalist['LAST_NAME'] ;
$first_name = $row_alphalist['FIRST_NAME'] ;
$employee_name = $first_name." ".$last_name ;
$pageCount = $pdf->setSourceFile('C:/wamp64/www/dbsmypay.com/bus_partners/BIR-forms/2316-new.pdf') ;
$tplIdx = $pdf->importPage(1, '/MediaBox') ;
$pdf->SetAutoPageBreak(false) ;
$pdf->addPage('P', 'Legal') ; // SETTING THE PAPER SIZE OF THE PDF
$pdf->useTemplate($tplIdx, 8, 12, 200, 320) ; // SETTING THE MARGIN LEFT TOP RIGHT BOTTOM
$pdf->SetFont('Arial') ;
$pdf->SetFontSize(10) ;
$pdf->SetTextColor(12, 12, 12) ;
$pdf->SetXY(46, 283) ;
$pdf->Write(0, $employee_name) ;
$file_location = "C:/wamp64/www/dbsmypay.com/per-day/bir-2316/2019/".$ee_numbers.".pdf" ;
$pdf->Output($file_location,'F') ;
}
我在下面有这段代码。如何根据 while 循环的数据生成多个 PDF?现在它只生成一个 PDF。例如,如果有 5 名员工,它还应该生成 5 个 PDF,每个 PDF 都有唯一的员工 name.Thanks Much.
<?php session_start() ; ?>
<?php include "../db_connection301.php" ; ?>
<?php include "../db_connection302.php" ; ?>
<?php include "../db_connection303.php" ; ?>
<?php include "../db_connection304.php" ; ?>
<?php include "../db_connection305.php" ; ?>
<?php
require_once('../../bus_partners/fpdf/fpdf/fpdf.php');
require_once('../../bus_partners/fpdf/fpdi/fpdi.php');
$pdf = new FPDI();
$query_data = "SELECT * FROM alphalist_compen_2019";
$result_alphalist = mysqli_query($connection303, $query_data ) ;
while ($row_alphalist = mysqli_fetch_array($result_alphalist)) {
$ee_numbers = $row_alphalist['EE_NUMBER'] ;
$last_name = $row_alphalist['LAST_NAME'] ;
$first_name = $row_alphalist['FIRST_NAME'] ;
$employee_name = $first_name." ".$last_name ;
$pageCount = $pdf->setSourceFile('C:/wamp64/www/dbsmypay.com/bus_partners/BIR-forms/2316-new.pdf') ;
$tplIdx = $pdf->importPage(1, '/MediaBox') ;
$pdf->SetAutoPageBreak(false) ;
$pdf->addPage('P', 'Legal') ; // SETTING THE PAPER SIZE OF THE PDF
$pdf->useTemplate($tplIdx, 8, 12, 200, 320) ; // SETTING THE MARGIN LEFT TOP RIGHT BOTTOM
$pdf->SetFont('Arial') ;
$pdf->SetFontSize(10) ;
$pdf->SetTextColor(12, 12, 12) ;
$pdf->SetXY(46, 283) ;
$pdf->Write(0, $employee_name) ;
}
$file_location = "C:/wamp64/www/dbsmypay.com/per-day/bir-2316/2019/".$ee_numbers.".pdf" ;
$pdf->Output($file_location,'F') ;
将您的 $pdf = new FPDI();
和 $pdf->Output($file_location,'F') ;
放入 while 循环中,如下所示:
<?php session_start() ; ?>
<?php include "../db_connection301.php" ; ?>
<?php include "../db_connection302.php" ; ?>
<?php include "../db_connection303.php" ; ?>
<?php include "../db_connection304.php" ; ?>
<?php include "../db_connection305.php" ; ?>
<?php
require_once('../../bus_partners/fpdf/fpdf/fpdf.php');
require_once('../../bus_partners/fpdf/fpdi/fpdi.php');
$query_data = "SELECT * FROM alphalist_compen_2019";
$result_alphalist = mysqli_query($connection303, $query_data ) ;
while ($row_alphalist = mysqli_fetch_array($result_alphalist)) {
$pdf = new FPDI();
$ee_numbers = $row_alphalist['EE_NUMBER'] ;
$last_name = $row_alphalist['LAST_NAME'] ;
$first_name = $row_alphalist['FIRST_NAME'] ;
$employee_name = $first_name." ".$last_name ;
$pageCount = $pdf->setSourceFile('C:/wamp64/www/dbsmypay.com/bus_partners/BIR-forms/2316-new.pdf') ;
$tplIdx = $pdf->importPage(1, '/MediaBox') ;
$pdf->SetAutoPageBreak(false) ;
$pdf->addPage('P', 'Legal') ; // SETTING THE PAPER SIZE OF THE PDF
$pdf->useTemplate($tplIdx, 8, 12, 200, 320) ; // SETTING THE MARGIN LEFT TOP RIGHT BOTTOM
$pdf->SetFont('Arial') ;
$pdf->SetFontSize(10) ;
$pdf->SetTextColor(12, 12, 12) ;
$pdf->SetXY(46, 283) ;
$pdf->Write(0, $employee_name) ;
$file_location = "C:/wamp64/www/dbsmypay.com/per-day/bir-2316/2019/".$ee_numbers.".pdf" ;
$pdf->Output($file_location,'F') ;
}