title: How can I render a web page on the server (no GUI) for printing?
body: <p>I'm trying to print pages pragmatically with a PHP script, to an office printer.</p>
  
  <p>Here's what I've got so far:</p>
  
  <p>I have a printer installed on the server, and I can send jobs to it with PHP via the command line's print command. I can also write plain text files with my PHP script, and then add them to the print cue. So printing PHP generated plain text files with PHP works just fine.</p>
  
  <p>The question is, how can I create printable files, using PHP, that actually incorporate layout and graphics? In other words, if I created a web page with images and css, and then displayed the page in Firefox, and clicked print, that's what I want to come off the printer. Except it needs to work on a system without a GUI, and without user intervention.</p>
  
  <p>So far I have these possible ideas:</p>
  
  <ul>
  <li><p>Use a PHP PDF library to generate a PDF file and add that to the print cue (very complicated to get the positioning right)</p></li>
  <li><p>Use the GD library to generate an image file (merging images and text into one page-sized image), and sending the final image to the printer.</p></li>
  </ul>
  
  <p>Both of the above are complicated though, and would be tedious to implement and maintain. I'm wondering if there might be a simpler solution? Laying out the page using html and CSS would be the easiest option. Is there a library or script that can produce a PDF of a rendered page from raw html/css markup?</p>
  
  <p>Or a way to run firefox (or another browser) in command line only mode, but has full rendering capabilities that could be sent to a pdf file or the printer?</p>
  
  <p>Long question short- I'm looking for a way to send a rendered html/css page to a printer...</p>
  
  <p>Any ideas?</p>