Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some kanji characters cannot be displayed #718

Open
thinh1995 opened this issue May 9, 2024 · 1 comment
Open

Some kanji characters cannot be displayed #718

thinh1995 opened this issue May 9, 2024 · 1 comment

Comments

@thinh1995
Copy link

thinh1995 commented May 9, 2024

I am using TCPDF latest version (6.7.5) to export PDF documents. In the document there are some Japanese kanji characters that cannot be displayed, but other characters is OK. I have tried using fonts like cid0jp, cid0cs, cid0cs, arialuni, ... but it still doesn't work. I also download Japanese fonts and add them to the library but the result is still the same. Below is the demo.php file and the result is an empty pdf file:

<?php 
require_once('tcpdf/tcpdf.php');

$pdf = new TCPDF('P', 'mm', 'A4', true, 'UTF-8', false);

$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);

$pdf->AddPage();

$string = "𠀋 𡈽 𡌛 𡑮 𡢽 𠮟 𡚴 𡸴 𣇄 𣗄";
$pdf->SetFont('cid0jp', '', 12);
$pdf->Cell(190, 10, $string, 0, 11);

$pdf->Output();

I researched and found that 4-byte kanji characters cannot be displayed. List of 4-byte characters on this page cannot be displayed:
https://ah-2.com/g1/2015/09/18/sjis2004_utf8_4byte_chars.html

Please give me some solutions or some examples for my case. Thanks a lot.

@thinh1995 thinh1995 changed the title Some kanji characters cannot be displayed when using TCPDF Some kanji characters cannot be displayed May 10, 2024
@ren1244
Copy link
Contributor

ren1244 commented May 12, 2024

I tested several libraries (dompdf, mpdf, tcpdf), and only mpdf supports Unicode beyond 0xFFFF.

The versions of the libraries tested are as follows:

  • tecnickcom/tcpdf: 6.7.5
  • dompdf/dompdf: 2.0.8
  • mpdf/mpdf: 8.2.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants