Ich arbeite mit Tcpdf, muss PDF generieren, Ich brauche Hilfe bei der Anzeige mehrerer Seiten. Die erste Seite enthält die Kundendetails, Nach der ersten Seite werden weitere Seiten entsprechend der for-Schleife hinzugefügt. und wie kann ich eine fixe Kopf- und Fußzeile zu diesem PDF hinzufügen. Ich muss das folgende Logo in der Kopfzeile und das Telefon und E-Mail des Agenten in der Fußzeile zeigen. hier ist mein CodeMüssen mehrere Seiten in tcpdf mit für for oder if Schleife für dynamischen Inhalt hinzufügen
if(isset($_GET['packid']))
{
$id=$_GET['packid'];
include_once 'db_connect.php';
include_once 'functions.php';
sec_session_start();
/*if(login_check($mysqli) == false)
{
header('location:../index.php');
exit();
}*/
require_once('tcpdf/tcpdf.php');
$obj_pdf = new TCPDF('P', PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
$obj_pdf->SetProtection(array('copy','modify'), '', '[email protected]#$)(*&15789537447344789', 0, null);
$obj_pdf->SetCreator(PDF_CREATOR);
$obj_pdf->SetTitle('Export HTML Table data to PDF using TCPDF in PHP');
$obj_pdf->SetHeaderData('', '', PDF_HEADER_TITLE, PDF_HEADER_STRING);
$obj_pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$obj_pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
$obj_pdf->SetDefaultMonospacedFont('helvetica');
$obj_pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
$obj_pdf->SetMargins(PDF_MARGIN_LEFT, '5', PDF_MARGIN_RIGHT);
$obj_pdf->setPrintHeader(false);
$obj_pdf->setPrintFooter(false);
$obj_pdf->SetAutoPageBreak(TRUE, 10);
$obj_pdf->SetFont('helvetica', '', 12);
$obj_pdf->AddPage();
$content = '';
$content .='
<html>
<head>';
$content .='
<style>
table, td, th {
border: 1px solid #ddd;
text-align: left;
}
table {
width: 100%;
}
th, td {
padding: 15px;
}
</style>';
$content .='
</head>
<body>';
//this is the agent details
$agent = $_SESSION['username'];
$pic= mysqli_query($mysqli,"SELECT * FROM rmt_users where rmt_uname = '$agent'");
//page 1 agent with client details
while($pp=mysqli_fetch_array($pic))
{
$image = '../'.$pp['rmt_ulogo'];
$phone = $pp['rmt_uemail'];
$email = $pp['rmt_uphone'];
}
$content .= '<h3 align="center">TOUR DETAILS</h3><br>
<table border="1" cellspacing="0" cellpadding="5">';
$content .='<tr align="center"><td colspan="2"><img src="'.$image.'" height="150px" width="auto" ></td><td colspan="2">Email : '.$email.' <br>Phone : '.$phone.'</td></tr>';
//agent detials ends
$queryagent= mysqli_query($mysqli,"SELECT * FROM rmt_bookings where b_id='$id'");
//ineed this section here to be page 1
while($rs=mysqli_fetch_array($queryagent))
{
$content .= '
<tr><td>Client Name</td><td colspan="3"> '.$rs["b_cname"].'</td></tr>
<tr><td>Client Address</td><td colspan="3"> '.$rs["b_caddress"].'</td></tr>
<tr><td>Client Phone</td><td colspan="3"> '.$rs["b_cphone"].'</td></tr>
<tr><td>Client Email</td><td colspan="3"> '.$rs["b_cemail"].'</td></tr>
<tr><td>No of Persons</td><td>No of Adults :'.$rs["b_cadult"].'</td>
<td>No of Child : '.$rs["b_cchild"].'</td>
<td>No of Infants : '.$rs["b_cinfant"].'</td></tr>
<tr><td>Package Name</td><td colspan="3"> '.$rs["b_pname"].'</td></tr>
<tr><td>Tour Location</td><td colspan="3"> '.$rs["b_location"].'</td></tr>
<tr><td>Depature Date</td><td colspan="3"> '.$rs["b_date"].'</td></tr>
<tr><td colspan="4"><b>Destination Details</b></td></tr>
';
$b_destinations = unserialize(base64_decode($rs['b_destinations']));
$b_nights = unserialize(base64_decode($rs['b_nights']));
foreach (array_combine($b_destinations[0], $b_nights[0]) as $desti=>$nights)
{
$content .='<tr><td colspan="2"> '.$desti.'</td><td colspan="2">Nights : '.$nights.'</td></tr></table>';
}
//page1 ends here
$b_hdest = unserialize($rs['b_hdest']);
$b_hname = unserialize($rs['b_hname']);
$b_hadd = unserialize($rs['b_hadd']);
$b_hphone = unserialize($rs['b_hphone']);
$b_hin = unserialize($rs['b_hin']);
$b_hout = unserialize($rs['b_hout']);
$b_hroom = unserialize($rs['b_hroom']);
$b_hmeal = unserialize($rs['b_hmeal']);
$b_haextra = unserialize($rs['b_haextra']);
$b_hcextra = unserialize($rs['b_hcextra']);
$b_hspecial = unserialize($rs['b_hspecial']);
$b_hincl = unserialize($rs['b_hincl']);
for($i=0;$i<count($b_hdest[0]);$i++){
//here multiple page will be add bcoz, the page will be added according this for loop.
$content .= '<table border="1" cellspacing="0" cellpadding="5">';
$content .='<tr align="center"><td colspan="2"><img src="'.$image.'" height="150px" width="auto" ></td><td colspan="2">Email : '.$email.' <br>Phone : '.$phone.'</td></tr>';
$content .='<tr><td colspan="4"><h4>Hotel details</h4></td></tr>';
$content .='<tr><td colspan="4"><b>Hotel Details '.($i+1).' : '.$b_hname[0][$i].' </b></td></tr>';
$content .='<tr><td><b>Destination</b></td><td><b>Address</b></td><td><b>Phone</b></td><td><b>Check Out Time</b></td></tr>';
$content .='<tr><td>'.$b_hdest[0][$i].'</td><td>'.$b_hadd[0][$i].'</td><td>'.$b_hphone[0][$i].'</td><td>10 AM</td></tr>';
$content .='<tr><td><b>Chekc In</b></td><td><b>Check Out</b></td><td><b>Rooms</b></td><td><b>Meals</b></td></tr>';
$content .='<tr><td>'.$b_hin[0][$i].'</td><td>'.$b_hout[0][$i].'</td><td>'.$b_hroom[0][$i].'</td><td>'.$b_hmeal[0][$i].'</td></tr>';
$content .='<tr><td><b>Extra Adult</b></td><td><b>Extra Child</b></td><td><b>Special</b></td><td><b>Inclusions</b></td></tr>';
$content .='<tr><td>'.$b_haextra[0][$i].'</td><td>'.$b_hcextra[0][$i].'</td><td>'.$b_hspecial[0][$i].'</td><td>'.$b_hincl[0][$i].'</td></tr>';
//page ends here
}
$content .='</table>';
$content .='</body></html>';
$obj_pdf->writeHTML($content);
ob_end_clean();
$obj_pdf->Output('tourdetails.pdf', 'I');
}
}