2017-04-11 33 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 Unicodeと右から左に記述する言語(https://tcpdf.org/が)と、私はsetSourceFileようないくつかの方法がないことがわかった。この問題

の解決に私の旅サポートされていません(定義されていないメソッドTCPDF :: setSourceFile()の呼び出し) FPDIとFPDFからクラスを継承するこの問題の解決策を見つけましたが、これを達成できなかったので、ここで停止しました...

親切に私を助けてくださいnすべてのライブラリを使用するように自分のコードを変更するので、英語とアラビア語の場合は問題にはなりません。

答えて

0

FPDIの前にFPDFの代わりにTCPDFが必要です。 FPDIはTCPDFを拡張します。

+0

ありがとうございました^ _ ^ – Learner

関連する問題