首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >OPOS PosPrinter.PrintNormal不打印

OPOS PosPrinter.PrintNormal不打印
EN

Stack Overflow用户
提问于 2013-04-16 10:12:06
回答 1查看 6.3K关注 0票数 2

以下是我的代码:

代码语言:javascript
复制
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。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-04-19 07:53:05

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

代码语言:javascript
复制
printer.PrintNormal(PrinterStation.Receipt, "test print 1\n"); 

从POS中获取关于.net的PrintNormal文档

Newline / Line Feed (10个十进制) 在行缓冲区中打印任何数据,并输入到下一行。(打印直线不需要回车。)

这是因为打印机必须一次打印一个完整的行,所以它等待直到您告诉它在开始打印之前您已经完成了一行,这允许您在需要时使用两个或多个PrintNormal调用一行打印输出来生成行数据(例如,在一个循环中)。

我已经在一个联网POS打印机(Tysso PRP-250)上运行了下面的代码,它用\n打印了这条线,没有它就没有。

代码语言:javascript
复制
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();
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16034319

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档