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

Windows IIS PHP 8.0.12 System error "'""c:\wkhtmltopdf\bin\wkhtmltopdf.exe" is not recognized as an internal or external command #318

Closed
andraskende opened this issue Nov 7, 2021 · 1 comment

Comments

@andraskende
Copy link

andraskende commented Nov 7, 2021

Hello,

I upgraded PHP from 7.4.16 to 8.0.12 on a windows server..
Fresh install of latest CakePHP 4.3.1 and CakePDF 4.1.1

Configure::write('CakePdf', [
    'engine' => [
        'className' => 'CakePdf.WkHtmlToPdf',
        'binary' => 'c:\wkhtmltopdf\bin\wkhtmltopdf.exe',
    ],
    'pageSize' => 'Letter',
]);

With php 7.4.16 is working fine, with PHP 8.0.12 errors out with:

System error "'""c:\wkhtmltopdf\bin\wkhtmltopdf.exe" --quiet --print-media-type --orientation "portrait" --page-size "Letter" --encoding "UTF-8" - -"' is not recognized as an internal or external command,
operable program or batch file.
" when executing command """c:\wkhtmltopdf\bin\wkhtmltopdf.exe" --quiet --print-media-type --orientation "portrait" --page-size "Letter" --encoding "UTF-8" - -"". Try using the binary/package provided on http://wkhtmltopdf.org/downloads.html
Cake\Core\Exception\CakeException

I figured by adding a condition works fine with php 8.0.12
https://github.com/FriendsOfCake/CakePdf/blob/master/src/Pdf/Engine/WkHtmlToPdfEngine.php#L153-L155

if ($this->_windowsEnvironment && PHP_MAJOR_VERSION < 8) {
    $command = '"' . $command . '"';
}

Could it be related to this change:

https://www.php.net/manual/en/migration80.incompatible.php
On Windows, the program execution functions (proc_open(), exec(), popen() etc.) using the shell, now consistently execute %comspec% /s /c "$commandline", which has the same effect as executing $commandline (without additional quotes).

Thank you!

Screen Shot 2021-11-07 at 2 36 08 PM

@andraskende andraskende changed the title Windows IIS PHP 8.0.1 System error "'""c:\wkhtmltopdf\bin\wkhtmltopdf.exe" is not recognized as an internal or external command Windows IIS PHP 8.0.12 System error "'""c:\wkhtmltopdf\bin\wkhtmltopdf.exe" is not recognized as an internal or external command Nov 7, 2021
@ADmad
Copy link
Member

ADmad commented Aug 31, 2022

Fixed

@ADmad ADmad closed this as completed Aug 31, 2022
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