mikehaertl / phpwkhtmltopdf

A slim PHP wrapper around wkhtmltopdf with an easy to use and clean OOP interface
MIT License
1.6k stars 238 forks source link

Error on Windows when use javascript #57

Closed PeuX closed 8 years ago

PeuX commented 10 years ago

Hi, first great work, thanks :) Now the issu : I try to use phpwkhtmltopdf with somme javascript but i got error with no text error : this is my error : Could not run command "C:\inetpub\wwwroot\Communication\Appli\script\..\includes\wkhtmltopdf_x64.exe" --encoding "UTF-8" --orientation "Landscape" --margin-bottom "10mm" --margin-top "20mm" --header-spacing "10" "C:\inetpub\wwwroot\Communication\Appli\script\..\..\Donnees\crises\200\upload\temp\1404832841_tmp_file.html" "C:\Windows\Temp\tmp5E63.tmp":

and this is the content of 1404832841_tmp_file.html : <!DOCTYPE html><html><head></head><BODY><div>foo</div><script type="text/javascript">document.write("bar");</script></BODY></HTML>

if i set the option disable-javascript, it generate the pdf but whithout "bar"

The same command in shell generate pdf.

what i tried get stdout and system() like you said here whitout success :(

If you have some idea... (sorry for my english )...

mikehaertl commented 10 years ago

It's probably a limitation of wkhtmltopdf. Have you tried to create the PDF on the command line from a file with the same content?

PeuX commented 10 years ago

Yes, and with the same content it generate the right pdf (wifht foo and bar) edit: and with the same command.

mikehaertl commented 10 years ago

Ok, I have no idea then. There's an error code but no error message, which is weird. Personally I don't ever use Windows for Server purposes (and never would :P) for exactly those reasons. Maybe it's an issue with proc_open(). You could play around with it and try if you can run other exe files.

PeuX commented 10 years ago

I can run the same command with phpwkhtmltopdf but with option disable-javascript and it work ...

mikehaertl commented 10 years ago

Weird. There must be some output from wkhtmltopdf - but it's not displayed. So we can only guess what's the real issue.

Did you try javascript-delay?

PeuX commented 10 years ago

Yes, but without any success. (i set 'javascript-delay'=>1000 )

mikehaertl commented 10 years ago

Ok, then you're on your own. I would try again to somehow obtain the error message. Read the PHP manual for proc_open() and how to get all outputs (stderr, stdout) and see, if something's there. Also check the error logs of your webserver, maybe something's there.

PeuX commented 10 years ago

already do like here but got blank result

mikehaertl commented 10 years ago

Have you tried from a command line PHP script? Maybe it prints out the error message there somehow. Also check the return value of proc_close(). Maybe it helps something.

PeuX commented 10 years ago

I try to use system() in place of proc_open and it work. but without any stdout exit ($out=system($command,$returnVal);)

So thanks for your time and great work anyway :) bye

mikehaertl commented 10 years ago

Ok, thanks for your report. I'll leave this issue open, just in case there are other windows users with the same problem.