-
Notifications
You must be signed in to change notification settings - Fork 238
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
Warning: proc_open(): CreateProcess failed, error code - 2 #56
Comments
Sorry, I don't use Windows, so I can't really help. Other Windows users seem to have no problem with the library. You will have to play around with proc_open() yourself to find out, what's wrong. I'd try to build a simple PHP script and use more and more complex shell commands with proc_open(). Hope this helps. |
There are a lot of issues with php https://bugs.php.net/bug.php?id=51800 https://bugs.php.net/bug.php?id=60120 https://bugs.php.net/bug.php?id=65650 One workaround is to run the command yourself using However, as far as I know, there's no way to get the command woithout actually running it. I've created a pull request that should address this issue. |
If we wanted to fix this, we should do so in the underlying https://github.com/mikehaertl/php-shellcommand. But I'm hesitant to do so. The problem seems only to happen with long output (longer than 4096 bytes) on windows.. So I wonder, if adding the |
Unfortunately, this is not quite so simple. I've tested on two machines, a i7 3.4Ghz desktop and a dual Xeon E5-2695 server, both running the same exact OS and IIS 7.5) On the desktop, the php script times-out when converting a 233Kb html file + 295K worth of images to a 757kb pdf. Increasing the time-out time (to hours) on php doesn't fix the problem. The strange thing is that while the script is running, the PDF in the temp directory is empty but immidiately after timing out, the PDF gets created correctly in the temp directory. I can't explain this behaviour. Things get even weirder in the server. Sometimes the above script works without any problem, other times it behaves like the desktop. It's totally unreliable.
I agree. What I propose is either:
|
It is used. See https://github.com/mikehaertl/phpwkhtmltopdf/blob/master/src/Pdf.php#L248.
So... there's an issue anyway, even on the shell? How can we know, that this is really related to I still recommend to try the |
No, I might have not explained the issue clearly. TEST 1I created the following script (gist) and tested it in both my Desktop and my Home Server. Results:
(produced phpWkHtmlToPdf command) TEST 2I changed Results
|
Yes, I know it's used but it's not being parsed. wkHtmlToPdf library writes progress to STDERR: see https://code.google.com/p/wkhtmltopdf/issues/detail?id=825. This is by deisgn since they support dumping the actual PDF to STDOUT. So what I meant was: since your library does not really use STDOUT for anything, and since wkHtmlToPdf dumps the progress to STDERR, regardless of it having error messages, using proc_open or exec is the same thing. Why? Because you can pipe STDERR to STDOUT (and STDOUT to Nul) with exec and then read from it which, in pratical terms it's the same as reading from STDERR with proc_open.
|
@tivie I've now update the php-shellcommand. You should be able to do this now: <?php
use mikehaertl\wkhtmlto\Pdf;
$pdf = new Pdf([
'commandOptions' => [
'useExec' => true,
],
]);
... Can you please help testing? |
@mikehaertl Thanks Michael. I will be testing it and post the results soon. |
@mikehaertl The new commandOption is working good (passed all my tests). However, error reporting is lacking. I've fixed this issue in this pull request. Michael, if you don't mind, please have a look. |
@mikehaertl I've created a command exec library that address inconsistencies between linux and windows environments. You might wanna consider using it to build your lib commands. https://github.com/tivie/command If you wish, I can help you implement this. |
@tivie That looks nice. Maybe something to consider for a 3.0 release. On the other hand, from looking at the code I couldn't actually find a big difference in the core part ( BTW you may also hit this problem: mikehaertl/php-shellcommand#6. Maybe worth adding to your class, too? |
@mikehaertl thanks. The only big difference is in the automatic selection of
Maybe add this:
Those two would be awesome.
|
use the bypass_shell options of proc_open to make it works on windows |
Hi,
I'm currently trying to use your wkhtmltopdf but I cannot get passed a Warning call saying :
Warning: proc_open() [function.proc-open]: CreateProcess failed, error code - 87 in Path/To/WkHtmlToPdf.php on line 325
I tried with a basic code given in the tutorial but it doesn't work.
$pdf = new WkHtmlToPdf;
$pdf->addPage('http://google.com');
$pdf->send();
The error code 87 stands for invalid parameter.
Anyone can help me ?
Thank you
The text was updated successfully, but these errors were encountered: