如何在 FPDF 中显示阿拉伯语数据



我正在使用PHP和FPDF来生成PDF。我的问题是,数据没有以阿拉伯语显示。如何在PDF的内容中显示阿拉伯语数据?

这是我的代码:

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

FPDF 不支持本机 UTF-8 字符,而仅支持 ISO-8859-1 或 Windows-1252。

您应该尝试生成自己的字体,但我认为这不是一件容易的事。看看这个答案以获得一些帮助。

最新更新