using Ip address for Printer With PosExplorer Opos SDK.Net using C#

205 views Asked by At

I had a code like this before using a device name of printer but we migrated and now using ip address on printers my existing code looks like this

...

internal void ProcessInformation()
        {
            
            PosExplorer posExplorer = new PosExplorer();
            DeviceCollection receiptPrinterDevices = posExplorer.GetDevices(DeviceType.PosPrinter);
            DeviceInfo receiptPrinterDevice = posExplorer.GetDevice(DeviceType.PosPrinter, "SRP2");
            PosPrinter printer = (PosPrinter)posExplorer.CreateInstance(receiptPrinterDevice);

            printer.Open();
            printer.Claim(10000);
            printer.DeviceEnabled = true;
            printer.PrintNormal(PrinterStation.Receipt, "test print 1");

        }

...

i need help for starting like how do i make a code using PosExplorer connecting the api to the printer using ip address and do a print with header and body format?

1

There are 1 answers

0
kunif On

How you specify it depends on the type of service object provided by the printer vendor and how it is set.

There seems to be no standardized general purpose method using the POS for.NET API.


A possible method would be to use the native POS for.NET module as the service object and use PosCommon.DevicePath Property (POS for .NET v1.12 SDK Documentation).

Remarks
The PosExplorer class tries to initialize the DevicePath property to the hardware path of the physical device by using the following algorithm:

1 and 2 are methods to write the information to be set in advance by another means.

  1. If the physical hardware supports Plug and Play and the Service Object is mapped to a specific hardware ID through the HardwareId custom attribute or a configuration XML file, the PosExplorer class sets the DevicePath property to the HardwarePath property of the physical device. Service Objects can typically use this DevicePath property to directly access the device.
  2. If the device does not support Plug and Play, but has been configured through Posdm.exe or WMI, the DevicePath property will be set to the path that is specified when the device was configured.

It is possible that 3 can be set dynamically when the application program is executed.

  1. If the device does not support Plug and Play and has not been configured through Posdm.exe or WMI, the DevicePath property will be set to empty string ("") and must be set by the Service Object before the Open method in the base/basic class can be called.

If you were using OPOS for your service object, you probably need to change the Windows registry settings, so there's nothing you can do when you run your application.


In any case, please ask your printer vendor if they support it and how to do it.