sprain / php-swiss-qr-bill

A PHP library to create Swiss QR bills | QR-Rechnung in PHP erstellen
MIT License
282 stars 82 forks source link

TcPpdfOutput and FpdfOutput do not support full utf-8 character set #131

Open onebeat opened 3 years ago

onebeat commented 3 years ago

Hello, i am using tcpdf as output option. Here is my code

$tcPdf = new TCPDF('P', 'mm', 'A4', true, 'UTF-8'); $tcPdf->setPrintHeader(false); $tcPdf->setPrintFooter(false); $tcPdf->AddPage(); $output = new QrBill\PaymentPart\Output\TcPdfOutput\TcPdfOutput($qrBill, 'en', $tcPdf); $output->setPrintable(false)->getPaymentPart();

Originally posted by @onebeat in https://github.com/sprain/php-swiss-qr-bill/issues/130#issuecomment-856123200

sprain commented 3 years ago

Please show us your result, too. Where and how does the utf8 issue appear?

onebeat commented 3 years ago

Hello, you can see it on pdf which i have uploaded... qrbill-issue.pdf

sprain commented 3 years ago

Thank you for the example.

I can confirm that TcPdfOutput and to some extent FpdfOutput do not fully support the utf8 charset. It works for characters like é, but others like ł or ą are displayed as ?.

Based on a quick Google search, this seems to be a widespread issue. It is discussed here, for instance.

Maybe @sdespont or @Franco2911 know how to fix this issue?

onebeat commented 3 years ago

Hello, i have solved issue with help of your link and my trying to digg up the part of code where QRbill uses fonts definition..

  1. download file on link here
  2. /path/to/tcpdf/tools/tcpdf_addfont.php -i /path/to/fonts/ArialUnicodeMS.ttf
  3. go to TcPdfOutput.php on line 25 then change to ArialUnicodeMS
  4. problem solved
  5. it would be greate to integrate in construct to change dynamic font
KamilPesek commented 3 years ago

As mentioned above, this is a problem of TcPpdf/Fpdf and ISO-8859-1 encoding. When usign TCPDF, the easiest is to set private const FONT = 'dejavusans'; in src/PaymentPart/Output/TcPdfOutput/TcPdfOutput.php:25

Just keep in mind that if you are using composer that you can't change it directly in vendor folder. Make own copy of it.

sprain commented 3 years ago

Just keep in mind that if you are using composer that you can't change it directly in vendor folder. Make own copy of it.

Or you provide a pr to fix it for good within this library 😉

KamilPesek commented 3 years ago

Just keep in mind that if you are using composer that you can't change it directly in vendor folder. Make own copy of it.

Or you provide a pr to fix it for good within this library 😉

Totally agree. If there will be time, I will look at it.

rebeb74 commented 2 weeks ago

I just switch from Fpdf to Tcpdf in my project. I didn't have problem before. But now, I have encoding issues with some characters ("é"). And only on native texte of swiss qr bill. If I manually replace helvetica to dejavusans in private "private const FONT = 'dejavusans';", it works well. Why did you revert your commit that added the possibility to change font please ? image

EDIT: I had version 4.6. After updating to version 4.15, it's working fine now. Sorry