如何在FPDF中显示阿拉伯数据? [英] How to display Arabic data in FPDF?
本文介绍了如何在FPDF中显示阿拉伯数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用PHP和FPDF生成PDF.我的问题是,数据没有以阿拉伯语显示.如何在PDF内容中显示阿拉伯数据?
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?
这是我的代码:
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.
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.
这篇关于如何在FPDF中显示阿拉伯数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文