title: Wkhtmltopdf fails to resolve host when executed from php
body: <p>I'm generating pdf from php using wkhtmltopdf, but I have peculiar problem. When the template doesn't use any external sources everything is fine. But when it imports anything over http/file protocol I get:</p>
  
  <pre><code>The exit status code '1' says something went wrong:
  stderr: ""
  stdout: "Loading pages (1/6)
  [&gt; ] 0%
  [======&gt; ] 10%
  [=======&gt; ] 13%
  [============================================================] 100%
  Counting pages (2/6) 
  [============================================================] Object 1 of 1
  Resolving links (4/6) 
  [============================================================] Object 1 of 1
  Loading headers and footers (5/6) 
  Printing pages (6/6)
  [&gt; ] Preparing
  [============================================================] Page 1 of 1
  Done 
  Exit with code 1 due to network error: HostNotFoundError 
  </code></pre>
  
  <p>Exception tells me that:
  <code>command: "D:\Programs\wkhtmlpdf\bin\wkhtmltopdf.exe" --lowquality "C:\Windows\TEMP\knp_snappy54d3831ed861e8.25642951.html" "C:\Windows\Temp\D60C.tmp".</code></p>
  
  <p>In this case it was <code>@import url(http://fonts.googleapis.com/css?family=Bree+Serif);</code> which caused this error, but I simply can't use any link if I want it to work from php. When run from command line, everything is ok. I've checked that php executes it from "SYSTEM" user, so I spawned myself a cmd window running as SYSTEM, and the pdf was created without any problems. Allow_url_fopen is enabled, openssl as well.</p>
  
  <p>I'm using KnpSnappyBundle which uses Knp snappy library, which uses wkhtmltopdf. 
  I've read all wkhtmltopdf related problems on SO, but couldn't find an answer.</p>
  
  <p>PHP 5.5.5, apache 2.4.4</p>
  
  <p>Thank you</p>
  
  <p>Update: It seems symfony console component does some magic with proc_open. </p>
  
  <p><code>$this-&gt;process = proc_open($commandline, $descriptors, $this-&gt;processPipes-&gt;pipes, $this-&gt;cwd, $this-&gt;env, $this-&gt;options);</code></p>
  
  <p>And the parameters var_dump is</p>
  
  <pre><code>string(227) "cmd /V:ON /E:ON /C "("D:\Programs\wkhtmlpdf\bin\wkhtmltopdf.exe" --lowquality "C:\Windows\TEMP\knp_snappy54d3949bd6e035.20793656.html" "C:\Windows\Temp\2627.tmp") 1&gt;"C:\Windows\Temp\sf_26C4.tmp" 2&gt;"C:\Windows\Temp\sf_26C5.tmp""" 
  array(3) {
      [0]=&gt; array(2) {
          [0]=&gt; string(4) "pipe" 
          [1]=&gt; string(1) "r" 
      } 
      [1]=&gt; array(3) {
          [0]=&gt; string(4) "file" 
          [1]=&gt; string(3) "NUL" 
          [2]=&gt; string(1) "w" 
      } 
      [2]=&gt; array(3) {
          [0]=&gt; string(4) "file" 
          [1]=&gt; string(3) "NUL" 
          [2]=&gt; string(1) "w" 
      } 
  } array(0) {
  
  } string(24) "D:\Web\e-diagnostyka\web" array(0) {
  
  } array(3) {
      ["suppress_errors"]=&gt; bool(true) 
      ["binary_pipes"]=&gt; bool(true) 
      ["bypass_shell"]=&gt; bool(true) 
  }
  </code></pre>