mikehaertl/php-pdftk

Unable to find file with diacritics in the filename.

jadamec opened this issue · 4 comments

Hi there,
it's unable to find files with diacritics in its name.

For example, for the file named 001- Form Čučoriedka 06-2022.pdf it shows an error Unable to find file. (even it exists and path is correct).

How to fix this, please?

From what I remember you had to do a couple of things to make this work. In any case the environment where you execute that command has to support a unicode aware locale (check with locale -a and check e.g. for something like en_US.utf8 or de_DE.utf8).

You then need to make sure, that the command is executed with that locale. You may also have to pass this as environment variable to proc_env(). You can do both via options:

$pdf = new Pdf($file, [
    'locale' => 'en_US.utf8',
    'procEnv' => [
        'LANG' => 'en_US.utf-8',
    ],
]);

Related: mikehaertl/php-shellcommand#7

Thanks, but adding this didn't solve the issue.

Did you check for the right locale? Also try to echo the command and see if it works manually on the command line:

echo $pdf->getCommand()->getExecCommand();

Oh well.. I was using a wrong locale, now it works perfectly! Thanks. :)