2017-04-11 15 views
0

PDF 템플릿 위에 텍스트를 쓰고 싶습니다.이 템플릿은 FPDF & FPDI 라이브러리를 사용하여 작성했습니다.FPDF 및 FPDI 및 TCPDF 사용

내 코드 :

<?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(); 
} 
?> 

문제는 아랍어 텍스트 (UTF-8 인코딩)를 작성하는 경우

이다는 텍스트가 물음표로 표시됩니다.

내가 그것을 사용 때 TCPDF 지원 UTF-8 유니 코드 및 오른쪽에서 왼쪽으로 쓰는 언어 (https://tcpdf.org/가)와, 내가 setSourceFile 같은 몇 가지 방법이 아니라는 것을 발견 발견이 문제

를 해결하는 나의 여행 (정의되지 않은 메서드 TCPDF :: setSourceFile() 호출) FPDI 및 FPDF에서 클래스를 상속하는이 문제에 대한 솔루션을 찾았으므로이 문제를 해결할 수 없으므로 여기에서 중단되었습니다.

친절하게 나를 도와주세요. n 모든 라이브러리를 사용하기 위해 코드를 변경하면 영어와 아라비아어의 경우 문제가되지 않습니다.

답변

0

FPDI 대신 FPDF 대신 TCPDF 만 필요합니다. FPDI는 TCPDF를 확장 할 것입니다.

+0

고맙습니다.^_ ^ – Learner