title: barcode print in c# web application
body: <p>Below code am using in web application for the barcode(zebra barcode printer) printing .if i give the print in application server i am able print .</p>
  
  <pre><code>[DllImport("winspool.Drv", EntryPoint = "WritePrinter", SetLastError = true,                                            ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]          
  public static extern bool WritePrinter(IntPtr hPrinter, IntPtr pBytes, Int32 dwCount,     out Int32 dwWritten);
  
  public static bool SendBytesToPrinter(string szPrinterName, IntPtr pBytes, Int32 dwCount)
  {
      Int32 dwError = 0, dwWritten = 0;
      IntPtr hPrinter = new IntPtr(0);
      DOCINFOA di = new DOCINFOA();
      bool bSuccess = false; // Assume failure unless you specifically succeed.
  
      //di.pDocName = "My C#.NET RAW Document";
      //di.pDataType = "RAW";
  
      // Open the printer.
      if (OpenPrinter(szPrinterName.Normalize(), out hPrinter, IntPtr.Zero))
      {
          // Start a document.
          if (StartDocPrinter(hPrinter, 1, di))
          {
              // Start a page.
              if (StartPagePrinter(hPrinter))
  
              {
                  // Write your bytes.
                  bSuccess = WritePrinter(hPrinter, pBytes, dwCount, out dwWritten);
                  EndPagePrinter(hPrinter);
              }
              EndDocPrinter(hPrinter);
  
          }
          ClosePrinter(hPrinter);
      }
      // If you did not succeed, GetLastError may give more information
      // about why not.
      if (bSuccess == false)
      {
          dwError = Marshal.GetLastWin32Error();
      }
      return bSuccess;
  }
  </code></pre>
  
  <p>Here <code>szPrinterName</code> is printer name from drop down box from application.
  here I am able to get the printer name installed in application server only and print will go to server.</p>
  
  <p>How do I get the <em>client</em> machine printer name and print in <em>client</em> machine printer ?</p>