pdf-php icon indicating copy to clipboard operation
pdf-php copied to clipboard

PDF does not show properly all Non ASCII characters

Open pedjas opened this issue 1 year ago • 2 comments

I am creating relatively simple PDF document but I fill it in with content that contains Serbian specific non-ASCII characters (both Latin and Cyrillic). Some character show up as expected but some are replaced with question mark character. It seems like code page issue.

Data I am using is all UTF8. I checked everything and I am sure that I provide proper UTF8 to Cezpdf

PDF looks like wrong code page is applied. I cannot find option to force UTF8 on PDF document creation. Is that possible?

Here is example of code I use: test.zip

I tried this example with few PHP versions and I always get the same result.

pedjas avatar Dec 06 '24 12:12 pedjas

Hi,

Although this is a very late reply, I did find some issues (I did try earlier, but I didn't want the script to win tonight) ... But I'm not completely sure that I didn't modify the library yet...

But still, 2 issues are certain, and these are in your code:

  • The Helvetica font doesn't allow Unicode (try times or arial)
  • The encryption line is a killer ... didn't try with other parameters, just remove the line with "set_encyption" (this could be a bug, but I don't think removing it is a big issue)

BR, Alain

AlainC-be avatar Sep 19 '25 21:09 AlainC-be

I downloaded the original version of the class...

After the call, also the line $pdf->isUnicode=true; should be added.

And as improvement for a next release, I think "isUnicode" could be added to the constructor of Cezpdf (line 108), and this then of course being forwarded to its parent. line 279: parent::__construct($size, $isUnicode);

Your file, modified issue185_orig.zip

(still didn't check why encryption is a killer here)

AlainC-be avatar Sep 20 '25 07:09 AlainC-be