title: How can I print a web page on a server?
body: <p>Suppose I develop a web page using the cool Google visualization API, and it does everything the user wants. They can the parameters, look at the graphs, and print the page to get a reasonable-looking report. All good.</p>
  
  <p>Now suppose I want to do the same thing server-side. For example, say we need a set of report generated at a specific time of day, printed to a PDF and emailed to a manager. It's not a user-initiated action, so we don't have a user's browser or their printer. We have a URL that would render the report if we had a browser, and that's it.</p>
  
  <p>Is there a good way to do this server-side? Is this just foolish? Has anyone done anything like that before? Do any of the major browsers have APIs that might provide such functionality?</p>
  
  <p>Keep in mind too that it's not just static HTML; probably javascript will be running first to shift the DOM around.</p>
  
  <p>I know we <em>could</em> implement a whole different reporting engine on the server side to do this, but that will <strong>(a)</strong> generate reports that look a bit different, and <strong>(b)</strong> require me to build/maintain two sets of functionality.</p>
  
  <p>Instead, I'd be happy if I could just render the page / pages I want in an invisible server-side browser and print it to a PDF (let's mostly ignore that step - I know any number of PDF printer drivers that could do this).</p>
  
  <p>I don't really want to do it ugly either - i.e. by starting a browser process and then sending keystrokes directly to the window either - that's just bound to fall apart with a slight nudge. The <a href="https://stackoverflow.com/questions/565308/server-side-pdf-printing-with-flash">only related question I found</a> had an answer like that.</p>
  
  <p>Any advice appreciated!</p>