Hey,
I'm now trying for hours to get wkhtmltopdf to run properly. Locally everything's fine, but on the test server with Windows 2008 R2, IIS 7 it just won't work. This is the error I get:
The exit status code '1' says something went wrong: stderr: "" stdout: ""
command: "C:\path\to\wkhtmltopdf.exe" --lowquality "http://www.google.com" "c:\test.pdf".
There is no error besides this general error code "1". The command works fine from command line and even if I just put the command directly in an exec-function. But it does not work with proc_open, which Symfony seems to use. Does anyone have an idea what the problem is or why there is no error?
Dealing with the exact same problem
Never mind .. I fixed it with the following config:
return array(
'pdf' => array(
'enabled' => true,
'binary' => '"C:\Program Files\wkhtmltopdf\bin\wkhtmltopdf.exe"',
'options' => array(),
),
'image' => array(
'enabled' => true,
'binary' => '"C:\Program Files\wkhtmltopdf\bin\wkhtmltoimage.exe"',
'options' => array(),
),
);
Hey,
your config looks exactly like mine, how did it solve your problem exactly? If you mean the double quotes, unfortunately, they don't change anything on my server.
I have the same problem,
started happenign out of the blue. switched down to "0.1.2" version but still not working.
I narrowed it down to being a problem with the Symfonys Process Class, used in the executeCommand method of the AbstractGenerator class.
$process = new \Symfony\Component\Process\Process($command, NULL, $this->env);
I solved the problem with a hack, replacing the executeCommand method in generate with directly executing the command:
public function generate($input, $output, array $options = array(), $overwrite = false)
{
if (null === $this->binary) {
throw new \LogicException(
'You must define a binary prior to conversion.'
);
}
$this->prepareOutput($output, $overwrite);
$command = $this->getCommand($input, $output, $options);
/** Workaround for Windows Server 2008 + IIS7 */
exec($command);
// list($status, $stdout, $stderr) = $this->executeCommand($command);
// $this->checkProcessStatus($status, $stdout, $stderr, $command);
/** Workaround End */
$this->checkOutput($output, $command);
}
I wasn't really satisfied with that solution, but it worked the last two months without any problems.
this answer on stackoverflow solve "exit status code 1"
Double quotes in single quotes, solved it for me on win 8.1 ('"C:\Program Files\wkhtmltopdf\bin\wkhtmltopdf.exe"')
I had this issue somewhere else again and finally found the reason. Symfonys Process class has a WindowsEnhancement, which uses cmd.exe and some temporary files, which are normally saved to c:\Windows\Temp. But because the IIS User "IUSR" had no permissions to write there, the whole thing failed.
There are multiple solutions:
I'm running Windows Server 2012 R2 + IIS + Symfony2.
Wkhtmltopdf 0.12.3.2 64 bit.
Path written as: "\"E:\wkhtmltopdf\bin\wkhtmltopdf.exe\"";
IUSR has all permissions on Windows\Temp.
It does not matter if Temp is used or I set:
temporary_folder: %kernel.cache_dir%/snappy #(with all permissions of course)
I always get:
The exit status code '1' says something went wrong:
stderr: ""
stdout: ""
command: "E:\wkhtmltopdf\bin\wkhtmltopdf.exe" --lowquality --footer-font-name "Verdana" --footer-font-size "9" --footer-left ...(and so on)"
Only solution is as above, modify the code to:
exec($command);
Any other workarounds for this or a possibility for a patch in AbstractGenerator?
Maybe you can try to deactivate the Windows enhancement in the Process class of Symfony and check, if it still fails.
I could try that, but what is the real difference here? It all ends up modifying files in vendor...
Well, if it is in fact Symfonys Process class, which causes the failure, then it's not this package that needs some changes. It's just to find the cause. I don't really remember what the Windows enhancement does, but it changes the path somehow and maybe there is the problem.
You could write your path without " and see if it works. Since you have no whitespaces in your path, it should make no difference.
Dealing with the exact same problem
Never mind .. I fixed it with the following config:
return array( 'pdf' => array( 'enabled' => true, 'binary' => '"C:\Program Files\wkhtmltopdf\bin\wkhtmltopdf.exe"', 'options' => array(), ), 'image' => array( 'enabled' => true, 'binary' => '"C:\Program Files\wkhtmltopdf\bin\wkhtmltoimage.exe"', 'options' => array(), ), );
What about real server?? Would you please help me.
I tried by both composer and that you are followed. 'binary' => '"C:\Program Files\wkhtmltopdf\bin\wkhtmltopdf.exe"', work fine but i can not do this in real server.
my solution after all steps above
i secure my site using valet secure to convert my website to ssl(https)
using laravel valet locally and run this command
valet secure laravel
I also get this issue in windows 10.
then I found this QA
and fixed it by changing in executeCommand function
vendor\knplabs\knp-snappy\src\Knp\Snappy\AbstractGenerator.php
$process->getExitCode()!=1?:0,
return [
$process->getExitCode,
$process->getOutput(),
$process->getErrorOutput(),
];
to
return [
$process->getExitCode()!=1?:0,
$process->getOutput(),
$process->getErrorOutput(),
];
I also get this issue in windows 10.
then I found this QA
and fixed it by changing in executeCommand function
vendor\knplabs\knp-snappy\src\Knp\Snappy\AbstractGenerator.php$process->getExitCode()!=1?:0,
return [ $process->getExitCode, $process->getOutput(), $process->getErrorOutput(), ];to
return [ $process->getExitCode()!=1?:0, $process->getOutput(), $process->getErrorOutput(), ];
Good Idea! But it doesn't show image
I also get this issue in windows 10.
then I found this QA
and fixed it by changing in executeCommand function
vendor\knplabs\knp-snappy\src\Knp\Snappy\AbstractGenerator.php$process->getExitCode()!=1?:0,
return [ $process->getExitCode, $process->getOutput(), $process->getErrorOutput(), ];to
return [ $process->getExitCode()!=1?:0, $process->getOutput(), $process->getErrorOutput(), ];
Good Idea! But it doesn't show image
I solved the error by removing included blades:
I removed @include('my_blade_name') from printable page
Most helpful comment
Dealing with the exact same problem
Never mind .. I fixed it with the following config: