0

I'm trying to print a ticket using .NET POS but i'm not able to get the Default printer.

 PosPrinter defaultPrinter = await PosPrinter.GetDefaultAsync();

I also tried this:

string deviceSelector =  PosPrinter.GetDeviceSelector();
PosPrinter printer = await PosPrinter.FromIdAsync(deviceSelector);

I have my thermal printer configured as default.

1 Answers1

0

Have you tried the way using the PosExplorer and the printer name? Snippet:

public PosPrinter GetPrinterByName(System.Windows.Forms.Form mainForm, string printerName)
{
  PosPrinter       printer  = null;
  PosExplorer      explorer = new PosExplorer(mainForm);
  DeviveCollection printers = explorer.GetDevices(DeviceType.PosPrinter);

  if (printers != null && printers.Count > 0)
  {
    for (int i = 0; i < printers.Count; i++)
    {
      if(0 == string.Compare(printerName, printers[i].ServiceObjectName))
      {
        printer = printers[i];
        break;
      }
    }
  }

  return printer;
}
KBO
  • 653
  • 7
  • 17
  • I'm unable to use Microsoft.PointOfService dll; I'm working on a Xamarin Forms project. I think i know what the problem is; That my printer is not supported in the POS for .net – Hugo Ureña Nov 28 '17 at 16:29