TCPDF UTF-8. Lithuanian symbols not showing up

前端 未结 15 696
-上瘾入骨i
-上瘾入骨i 2020-12-01 06:47

Im using latest TCPDF version(5.9). But have some strange problems with encoding. I need Lithuanian language symbols like: ąčęėįšųūž. But get only few of it. Other remain li

相关标签:
15条回答
  • 2020-12-01 07:05

    I had the same issue with Romanian characters and the problem wasn't the encoding, LC_CTYPE or other setting from TCPDF, but the font I used. I mention that I used TWIG templating with Courier font. You can try to change your font to freeserif

    0 讨论(0)
  • 2020-12-01 07:05

    change the font to show normally ₹ and Lithuanian symbols

    $pdf->SetFont('cid0cs', '', 12);
    
    0 讨论(0)
  • 2020-12-01 07:10

    You u have problem to read character like Karnātaka from database and display like this karn?taka I mean "?" which we don't want then do following things :

    1. Define charset for the connection (mysql_set_charset()):

      $con = mysql_connect("localhost","root","");
      
      if (!$con)
      {
          die('Could not connect: ' . mysql_error());
      }
      mysql_select_db("database_name", $con) or die(mysql_error());
      mysql_set_charset('utf8',$con);
      
    2. Use $pdf->SetFont('DejaVuSerif', '', 10); instead of $pdf->SetFont('helvetica', 'B', 12);

      • For TCPDF Library of the PHP read character like Rājasthān instead of R?jasth?n from database
    0 讨论(0)
  • 2020-12-01 07:10
    $fontname = $pdf->addTTFfont('C:\xampp\htdocs\copyshop\fonts\07-TH-Sarabun-PSK\THSarabun.ttf', 'TrueTypeUnicode', '', 32);
        $pdf->SetFont($fontname, '', 16,'',FALSE); //Working
    
    0 讨论(0)
  • 2020-12-01 07:13

    Set the $unicode parameter on the TCPDF constructor to false and the $encoding parameter to 'ISO-8859-1' or some other character map.

    This will help you:

    Default for UTF-8 unicode:

    $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
    

    Example of constructor for European charset:

    $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, false, 'ISO-8859-1', false);
    
    0 讨论(0)
  • 2020-12-01 07:13

    With dejavusans font it worked fine for both Russian and Latvian letters.

    0 讨论(0)
提交回复
热议问题