 <p>The easiest way for executing phantomjs from C# code is using wrapper like <a href="https://www.nuget.org/packages/NReco.PhantomJS/" rel="nofollow">NReco.PhantomJS</a>. The following example illustrates how to use it for rasterize.js:</p> <pre><code>var phantomJS = new PhantomJS(); phantomJS.Run( "rasterize.js", new[] { "https://www.google.com", outFile} ); </code></pre> <p>Wrapper API has events for stdout and stderr; also it can provide input from C# Stream and read stdout result into C# stream. </p>