如何在名为FPDI的php库中设置UTF-8编码?这是图书馆:https://www.setasign.com/products/fpdi/manual/
代码:
$pdf = new Fpdi();
$pdf->AddPage();
$pdf->setSourceFile('PdfDocument.pdf');
$tplIdx = $pdf->importPage(1);
$pdf->useTemplate($tplIdx, 10, 10, 100);
$pdf->SetFont('Helvetica');
$pdf->SetTextColor(255, 0, 0);
$pdf->SetXY(30, 30);
$pdf->Write(0, 'Za?ó?ci? g??l? ja??');
$pdf->Output();
Run Code Online (Sandbox Code Playgroud)
[解]
首先:我必须添加适当字母的新字体
$pdf->AddFont('DejaVu','','DejaVuSansCondensed.php');
$pdf->SetFont('DejaVu', '', 10, '', false);
Run Code Online (Sandbox Code Playgroud)
SECOND:关于FPDI用户的FPDF库:有可能的编码:
cp1250 (Central Europe)
cp1251 (Cyrillic)
cp1252 (Western Europe)
cp1253 (Greek)
cp1254 (Turkish)
cp1255 (Hebrew)
cp1257 (Baltic)
cp1258 (Vietnamese)
cp874 (Thai)
ISO-8859-1 (Western Europe)
ISO-8859-2 (Central Europe)
ISO-8859-4 (Baltic)
ISO-8859-5 (Cyrillic)
ISO-8859-7 (Greek)
ISO-8859-9 (Turkish)
ISO-8859-11 (Thai)
ISO-8859-15 (Western Europe)
ISO-8859-16 (Central Europe) …Run Code Online (Sandbox Code Playgroud) 我们有几个包含Windows-1252字符的数据库字段:
an example pain— if you’re
Run Code Online (Sandbox Code Playgroud)
这些值映射到此列表中的所需值:
http://www.i18nqa.com/debug/utf8-debug.html
我尝试了各种htmlentites,mb_detect_encoding,uft8_decode等的排列,但还没有能够将这些值转换为:
一个例子的痛苦 - 如果你是
如何将这些字符转换为php中列出的值?
我正在使用FPDF库生成一些订单确认,这非常有用.但是现在我需要一些中文字符.我现在已经搜索了很多个小时,但没有找到可行的解决方案.是否可以使用FPDF支持中文字符,还是可以替代支持它的FPDF?
所有字符都与常规文本混合,并存储在MySQL数据库中.PDF文档仅在打印汉字时显示unicode.