C# OPOS PosPrinter.PrintNormal不打印

C# OPOS PosPrinter.PrintNormal不打印,c#,opos,pos-for-.net,C#,Opos,Pos For .net,以下是我的代码: PosExplorer posExplorer = new PosExplorer(); DeviceCollection receiptPrinterDevices = posExplorer.GetDevices(DeviceType.PosPrinter); DeviceInfo receiptPrinterDevice = posExplorer.GetDevice(DeviceType.PosPrinter,"SRP2"); PosPrinter printer =

以下是我的代码:

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");
我调试了一下,一切都进行得无一例外,已经确认目标打印机是正确的,但是打印机没有打印任何东西。有没有哪一步我做错了?非常感谢您的指导。谢谢



如果有帮助,我的打印机接口将通过以太网连接到特定的IP

问题似乎是您没有在
PrintNormal
字符串的末尾发送新行字符(
\n
),没有它,服务对象只会缓冲行数据,等待看到
\n
后再将数据发送到设备

printer.PrintNormal(PrinterStation.Receipt, "test print 1\n"); 
从POS for.net文档的
PrintNormal

换行符/换行符(10位小数)

打印行缓冲区中的任何数据,并馈送到下一个打印行。(打印行不需要回车。)

这是因为打印机必须一次打印一整行,所以它会等到您告诉它您已经完成了一行后再开始打印,这允许您使用2个或更多的
PrintNormal
调用来生成单行打印输出,以根据需要(例如,在循环中)生成行数据

我已经在联网POS打印机(Tysso PRP-250)上运行了以下代码,它使用打印行,没有打印行就不会打印

PosExplorer posExplorer = new PosExplorer();
DeviceInfo receiptPrinterDevice = posExplorer.GetDevice(DeviceType.PosPrinter, "SRP2");
PosPrinter printer = posExplorer.CreateInstance(receiptPrinterDevice) as PosPrinter;

printer.Open();
printer.Claim(10000);
if (printer.Claimed) 
{
    printer.DeviceEnabled = true;
    printer.PrintNormal(PrinterStation.Receipt, "test print 1\n");
    printer.DeviceEnabled = false;   
}
printer.Release();
printer.Close();

问题似乎是您没有在
PrintNormal
字符串的末尾发送新行字符(
\n
),没有它,服务对象只会缓冲行数据,直到看到
\n
,然后再将数据发送到设备

printer.PrintNormal(PrinterStation.Receipt, "test print 1\n"); 
从POS for.net文档的
PrintNormal

换行符/换行符(10位小数)

打印行缓冲区中的任何数据,并馈送到下一个打印行。(打印行不需要回车。)

这是因为打印机必须一次打印一整行,所以它会等到您告诉它您已经完成了一行后再开始打印,这允许您使用2个或更多的
PrintNormal
调用来生成单行打印输出,以根据需要(例如,在循环中)生成行数据

我已经在联网POS打印机(Tysso PRP-250)上运行了以下代码,它使用打印行,没有打印行就不会打印

PosExplorer posExplorer = new PosExplorer();
DeviceInfo receiptPrinterDevice = posExplorer.GetDevice(DeviceType.PosPrinter, "SRP2");
PosPrinter printer = posExplorer.CreateInstance(receiptPrinterDevice) as PosPrinter;

printer.Open();
printer.Claim(10000);
if (printer.Claimed) 
{
    printer.DeviceEnabled = true;
    printer.PrintNormal(PrinterStation.Receipt, "test print 1\n");
    printer.DeviceEnabled = false;   
}
printer.Release();
printer.Close();

声明的
值是多少?调用
打印机后。索赔(10000)?您是否可以使用打印机附带的opos设置程序(如果提供了)打印到打印机上?您可能还需要检查
receiptPrinterDevice.Description
,以确保设备信息是您认为的。您好,声明的值为“TRUE”,说明确认我使用的是正确的打印机,而不是模拟器,有什么想法吗?谢谢..通常打印机OPOS驱动程序附带一个设置实用程序,允许您设置逻辑名称(在您的情况下是
SRP2
),如果是,请尝试从此util发送测试打印。由于它是一台网络打印机,请确保您的防火墙没有阻止您的程序/端口,您可以尝试暂时禁用防火墙和防病毒软件,以查看它是否在关闭防火墙和防病毒软件的情况下打印。您的代码看起来很好,但似乎没有使用
receiptPrinterDevices
。是的,您尝试过从Util打印,但仍然无法通过脚本打印任何内容。
声明的值是多少?调用
打印机后。索赔(10000)?您是否可以使用打印机附带的opos设置程序(如果提供了)打印到打印机上?您可能还需要检查
receiptPrinterDevice.Description
,以确保设备信息是您认为的。您好,声明的值为“TRUE”,说明确认我使用的是正确的打印机,而不是模拟器,有什么想法吗?谢谢..通常打印机OPOS驱动程序附带一个设置实用程序,允许您设置逻辑名称(在您的情况下是
SRP2
),如果是,请尝试从此util发送测试打印。由于它是一台网络打印机,请确保您的防火墙没有阻止您的程序/端口,您可以尝试暂时禁用防火墙和防病毒软件,以查看它是否在关闭防火墙和防病毒软件的情况下打印。您的代码看起来不错,尽管似乎没有使用
receiptPrinterDevices
。是的,您尝试过从Util打印,但仍然无法通过脚本打印任何内容。。