How to display Arabic data in FPDF?

别说谁变了你拦得住时间么 提交于 2019-12-13 01:02:07

问题


I am using PHP and FPDF to generate a PDF. My problem is, the data is not displaying in Arabic. How to show Arabic data in content of PDF?

Here is my code:

require('include/fpdf/fpdf.php');
class PDF extends FPDF {

// Page header
function Header()
{

    $this->Image('include/fpdf/tutorial/logo.png',10,6,30);// Logo
    $this->SetFont('Arial','B',15);// Arial bold 15
    $this->Cell(80);// Move to the right
    $this->Cell(30,10,'العنوان',1,0,'C');// Title
    $this->Ln(20);// Line break
}

// Page footer
function Footer()
{

    $this->SetY(-15);// Position at 1.5 cm from bottom
    $this->SetFont('Arial','I',8);// Arial italic 8
    $this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');// Page number
}}


    // Instanciation of inherited class
    $pdf = new PDF();

    $pdf->AliasNbPages();

    $pdf->AddPage();

    $pdf->SetFont('Times','',12);

    for($i=1;$i<=40;$i++)

    $pdf->Cell(0,10,' تجربة '.$i,0,1);

    $pdf->Output();

回答1:


FPDF doesn't support natively UTF-8 characters, but only ISO-8859-1 or Windows-1252.

You should try to generate your own font, but I don't find that an easy task. Take a look at this answer for some help.



来源:https://stackoverflow.com/questions/27397878/how-to-display-arabic-data-in-fpdf

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!