【问题标题】:OPOS PosPrinter.PrintNormal not printingOPOS PosPrinter.PrintNormal 不打印
【发布时间】:2013-04-08 16:43:55
【问题描述】:

下面是我的代码:

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。

【问题讨论】:

  • Claimed 的值是多少?致电printer.Claim(10000);后?并且您可以使用打印机随附的opos 设置程序(如果提供的话)打印到打印机吗?
  • 您可能还需要检查 receiptPrinterDevice.Description 以确保 DeviceInfo 是您认为的那样。
  • 您好,声称的值为“TRUE”,并且描述确认我得到了正确的打印机,而不是模拟器,有什么想法吗?谢谢..
  • 通常打印机 OPOS 驱动程序附带一个设置实用程序,允许您设置逻辑名称(在您的情况下为 SRP2),如果是这样,请尝试从该实用程序发送测试打印。作为网络打印机,请确保您的防火墙没有阻止您的程序/端口,您可以尝试暂时禁用防火墙和防病毒软件,看看它是否在关闭它们的情况下打印。您的代码看起来不错,虽然 receiptPrinterDevices 似乎没有被使用。
  • 是的,已经尝试从 Util 打印并且它可以工作,但不知何故仍然无法通过脚本打印任何内容..

标签: c# opos pos-for-.net


【解决方案1】:

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

printer.PrintNormal(PrinterStation.Receipt, "test print 1\n"); 

来自PrintNormal上的 .net 文档的 POS

换行/换行(10 进制)

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

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

我在联网的 POS 打印机 (Tysso PRP-250) 上运行了以下代码,使用 \n 打印行,没有它则不打印。

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();

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-30
    • 1970-01-01
    • 2015-09-03
    • 2013-04-13
    • 2012-08-30
    • 2013-03-15
    • 2019-07-21
    • 2020-05-12
    相关资源
    最近更新 更多