Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/227.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用FPDF&;FPDI&;TCPDF_Php_Utf 8_Tcpdf_Fpdf_Fpdi - Fatal编程技术网

Php 使用FPDF&;FPDI&;TCPDF

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

我想在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_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