mikehaertl / php-pdftk

A PDF conversion and form utility based on pdftk
MIT License
939 stars 124 forks source link

Unable to find file with diacritics in the filename. #286

Closed jadamec closed 2 years ago

jadamec commented 2 years ago

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?

mikehaertl commented 2 years ago

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: https://github.com/mikehaertl/php-shellcommand/issues/7

jadamec commented 2 years ago

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

mikehaertl commented 2 years ago

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();
jadamec commented 2 years ago

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