简体   繁体   English

TCPDF 有些字符看不到

[英]TCPDF Some characters cannot be seen

I am not able to see some of the characters, generated by TCPDF.我看不到 TCPDF 生成的某些字符。

php file: php 档案:

<?php
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'cp1254', false);
$pdf->AddPage();
$pdf->SetFont('dejavusans', ' ', 10);
$pdf->Write(0, 'helloşüğı');
$pdf->Output('hello_world.pdf');
?>

Output is this: hello Output 是这样的:你好

By the way i am using dejavusans fonts, which supports my alphabet's characters.顺便说一下,我使用的是 dejavusans fonts,它支持我的字母表字符。 (Turkish) (土耳其)

Set the $unicode parameter on the TCPDF constructor to false and the $encoding parameter to 'ISO-8859-1' or some other character map. 将TCPDF构造函数上的$unicode参数设置为false,将$ encoding参数设置为'ISO-8859-1'或其他字符映射。

Example of constructor for European charset: 欧洲字符集的构造函数示例:

 $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT,
        false, 'ISO-8859-1', false);

Try with this. 试试这个。

i solved the same problem with the following usage我用以下用法解决了同样的问题

$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, 

PDF_PAGE_FORMAT, true, 'UTF-8', false);
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
$pdf->setFontSubsetting(true);
// font for turkish characters ex: ş, ç, ı, ğ, ü, ö
$pdf->SetFont('dejavusans', '', 10, '', true);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM