title: WPF C# Print image in Zebra GK888t (ZDesigner) printer
body: <p><strong>Environment:</strong> </p>
  
  <ul>
  <li>Zebra (ZDesigner) GK888t EPL label printer</li>
  <li>10cm x 5cm paper</li>
  <li>Windows drivers ( any other do not work )</li>
  <li>Configurated printer options in Windows printer preferences
  
  <ul>
  <li>width of paper: 10cm</li>
  <li>height of paper: 5cm</li>
  <li>media settings : direct thermal</li>
  </ul></li>
  </ul>
  
  <p><strong>Problem</strong>: I want to print generated image, but I don't want to show PrintDialog for user.
  User can only print image by pressing button "PRINT", but i can't achieve it.</p>
  
  <p>Working version <strong>with</strong> PrintDialog dialog:</p>
  
  <pre><code>Image image = new Image();
  
  PrintDialog dlg = new PrintDialog();
  bool? result = dlg.ShowDialog();
  
  PrintCapabilities capabilities = dlg.PrintQueue.GetPrintCapabilities(dlg.PrintTicket);
  
  Size sz = new Size(capabilities.PageImageableArea.ExtentWidth, capabilities.PageImageableArea.ExtentHeight);
  
  image.Measure(sz);
  image.Arrange(
      new Rect(
          new Point(
              capabilities.PageImageableArea.OriginWidth,
              capabilities.PageImageableArea.OriginHeight
          )
          ,sz
      )
  );
  
  dlg.PrintVisual(image, "Print a Large Image");
  </code></pre>
  
  <p>Version <strong>without</strong> PrintDialog dialog:</p>
  
  <pre><code>Image image = new Image();
  
  PrintDialog dlg = new PrintDialog();
  dlg.PageRange = new PageRange(1);
  PrintQueue printQueue = new PrintServer()
                              .GetPrintQueues().ToList()
                              .FirstOrDefault(x =&gt; x.FullName.Contains("ZDesigner GK888t (EPL)"));
  dlg.PrintQueue = printQueue;
  
  PrintCapabilities capabilities = dlg.PrintQueue.GetPrintCapabilities(dlg.PrintTicket);
  
  Size sz = new Size(capabilities.PageImageableArea.ExtentWidth, capabilities.PageImageableArea.ExtentHeight);
  
  dlg.PrintTicket.PageMediaSize = new PageMediaSize(sz.Width, sz.Height);
  
  image.Measure(sz);
  image.Arrange(
      new Rect(
          new Point(
              capabilities.PageImageableArea.OriginWidth,
              capabilities.PageImageableArea.OriginHeight
          )
          ,sz
      )
  );
  
  dlg.PrintVisual(image, "Print a Large Image");
  </code></pre>
  
  <p>But this code do not work, Zebra printer in this case do not print, or print blank label, or stop in the middle of label and stop working (flashing red light)</p>
  
  <p><strong>Question</strong>: How to fix it? I guess it doesn't work well because configuration of printer isn't apply ( like paper size or media settings - direct thermal option) because of getting it from PrintQueues. Any other ways to print generated image?</p>