title: Printing via Winspool
body: <p>I'm trying to set up a kind of print service for a website to communicate with and send printable documents to (pdf, html, excel). I decided on Go.</p>
  
  <p>I created the simple program below. On some PCs it works (Windows 7) on other ones (Windows 8) it doesn't work (right). When it doesn't work the job is visible in the print queue for less then a second and then disappears. The code doesn't output any errors. I can't find anything in the Windows event log.</p>
  
  <p>I also tried a RawPrinter example in c++ I could find online but that shows the same behavior.</p>
  
  <p>Does anyone know what I'm doing wrong? :(</p>
  
  <pre><code>package main
  
  import (
      "fmt"
      "code.google.com/p/brainman/printer"
  )
  
  
  func main() {
      defaultPrinterName, _ := printer.Default()
      fmt.Println(defaultPrinterName)
      p, err := printer.Open(defaultPrinterName)
  
      if err != nil {
          fmt.Println("Open failed: %v", err)
      }
  
      defer p.Close()
  
      err = p.StartDocument("my document", "RAW")
  
      if err != nil {
          fmt.Println("StartDocument failed: %v", err)
      }
  
      defer p.EndDocument()
  
      err = p.StartPage()
  
      if err != nil {
          fmt.Println("StartPage failed: %v", err)
      }
  
      str := "testing 123"
      mySlice := []byte(str)
  
      _, err = p.Write(mySlice)
  
      if err != nil {
          fmt.Println("Write failed: %v", err)
      }
  
      err = p.EndPage()
  
      if err != nil {
          fmt.Println("EndPage failed: %v", err)
      }
  }
  </code></pre>