Php 使用FPDF&;FPDI&;TCPDF
我想在PDF模板上写一些文本,我使用以下方法实现了这一点: FPDF和FPDI库 我的代码:Php 使用FPDF&;FPDI&;TCPDF,php,utf-8,tcpdf,fpdf,fpdi,Php,Utf 8,Tcpdf,Fpdf,Fpdi,我想在PDF模板上写一些文本,我使用以下方法实现了这一点: FPDF和FPDI库 我的代码: <?PHP include_once('fpdf.php'); require_once('fpdi.php'); $dbhost="xxx"; $dbuser="xxx"; $con = mysqli_connect($dbhost,$dbuser, ""); if (!$con) { printf("Connect failed: %s\n", mysqli_co
<?PHP
include_once('fpdf.php');
require_once('fpdi.php');
$dbhost="xxx";
$dbuser="xxx";
$con = mysqli_connect($dbhost,$dbuser, "");
if (!$con)
{
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
mysqli_select_db($con,'ecertificate');
$id = $_GET['id'];
$result = mysqli_query($con,"SELECT `eventinfo`.`Date`,`eventinfo`.`template`,`eventinfo`.`cer_title`, `attendeesinfo`.`fullName`,
`attendeesinfo`.`email`,`attendeesinfo`.`eventID`
FROM `attendeesinfo` INNER JOIN `eventinfo` ON
`attendeesinfo`.`eventID`=`eventinfo`.`ID` WHERE `attendeesinfo`.ID='$id'");
if (mysqli_num_rows($result) > 0)
{
while($row = mysqli_fetch_assoc($result))
{
$cer_title =$row['cer_title'];
$date =$row['Date'];
$template =$row['template'];
$fullName =$row['fullName'];
$email =$row['email'];
$event_ID = $row['eventID'];
}
$newDate = date("d-m-Y", strtotime($date));
$pdf =& new FPDI();
$pdf->addPage('L');
$pagecount = $pdf->setSourceFile('template/'.$template);
$tplIdx = $pdf->importPage(1);
$pdf->useTemplate($tplIdx);
$pdf->SetFont('Times','IB',30);
$pdf->SetTextColor(0,0,0);
$pdf->SetXY(0,62);
$pdf->Cell(0, $height, $fullName, 0, 0, 'C');
$pdf->SetXY(0, 102);
$pdf->Cell(0, $height, $cer_title, 0, 0, 'C');
$pdf->SetFont('Times','IB',20);
$pdf->SetXY(0, 140);
$pdf->Cell(0, $height, $newDate, 0, 0, 'C');
$pdf->Output();
}
?>
只需在FPDI之前使用TCPDF而不是FPDF。届时FPDI将扩展TCPDF