【问题标题】:Print and open drawer with Epson T20 (thermal printer)使用 Epson T20(热敏打印机)打印和打开抽屉
【发布时间】:2012-01-21 10:35:37
【问题描述】:

我搜索了很多,我在这里找到了 Posexplorer 的示例,但我的打印机是 USB 并且我读过 PosExplorer 是用于并行的。我不知道如何使用打印机打印以及如何将代码发送到打印机以打开抽屉。

我正在使用以下代码向打印机发送转义序列:

string ESC = Convert.ToString((char)27);
string logo=Convert.ToString(ESC+"|tL");
_oposPrinter.PrintNormal(PrinterStation.Receipt, logo);
_oposPrinter.PrintNormal(PrinterStation.Receipt, "Print example\n");
_oposPrinter.PrintNormal(PrinterStation.Receipt, Convert.ToString((char)27 + "|#fP"));

调试时到达行:

_oposPrinter.PrintNormal(PrinterStation.Receipt, logo);

_oposPrinter.PrintNormal(PrinterStation.Receipt, Convert.ToString((char)27 + "|#fP"));

打印机不打印任何东西。

【问题讨论】:

  • 将打印机设置为默认打印机(纯文本驱动程序)并像打印任何其他文档一样打印。要打开抽屉,您需要能够访问 COM 端口并知道要发送什么信号。
  • 谢谢,我已经用这种方式打印了,但我需要打开抽屉。无论如何,谢谢。

标签: c# thermal-printer pos-for-.net


【解决方案1】:

如果您正在寻找一个非常轻量级的解决方案无需第三方安装 Microsoft POS for .NET 等软件。

你需要包含RawPrinterHelper功能(可以从https://support.microsoft.com/en-us/help/322091/how-to-send-raw-data-to-a-printer-by-using-visual-c-.net下载)

然后发送特定的钱箱代码以将其打开到它所连接的打印机。

例如,在 Epson TM88 上,此功能将打开它。

SendStringToPrinter(printerName, System.Text.ASCIIEncoding.ASCII.GetString(new byte[] { 27, 112, 48, 55, 121 }));

其他打印机可​​能需要其他代码序列。

Citizen
27,112,0,50,250
Epson 
27,112,48,55,121
27,112,0,25,250
27,112,48,25,250
IBM
7

...(在http://keyhut.com/popopen.htm查看更多代码,包括自动切割器或第二个抽屉)

【讨论】:

  • 非常感谢您的回答,现在我使用 microsoft pos for .net 进行打印,但它是一个不错的选择。
  • 谢谢,这是一个非常好的解决方案,比安装 POS.NET 驱动程序要好得多
【解决方案2】:

我知道此代码适用于正常打印。我没有测试过钱箱部分,但我相信这是正确的命令,您只需要知道正确的参数即可。

此代码假定您已使用 Epson 提供的实用程序 SetupPos.exe 设置了打印机。我不记得我在哪里得到它,但EpsonExpert.com 可能是个不错的地方。然后只需确保您传递了正确的 LDN(您在 setuppos 软件中进行了设置)。

    PosExplorer explorer = null;
    DeviceInfo _device;
    PosPrinter _oposPrinter;
string LDN;

    explorer = new PosExplorer();
    _device = explorer.GetDevice(DeviceType.PosPrinter, LDN);
    _oposPrinter = (PosPrinter)explorer.CreateInstance(_device);
    _oposPrinter.Open();
    _oposPrinter.Claim(10000);
    _oposPrinter.DeviceEnabled = true;
 // normal print
    _oposPrinter.PrintNormal(PrinterStation.Receipt, yourprintdata); 
// pulse the cash drawer pin  pulseLength-> 1 = 100ms, 2 = 200ms, pin-> 0 = pin2, 1 = pin5
    _oposPrinter.PrintNormal(PrinterStation.Receipt, (char)16 + (char)20 + (char)1 + (char)pin + (char)pulseLength); 

// cut the paper
    _oposPrinter.PrintNormal(PrinterStation.Receipt, (char)29 + (char)86 + (char)66)

// print stored bitmap
    _oposPrinter.PrintNormal(PrinterStation.Receipt, (char)29 + (char)47 + (char)0)

【讨论】:

  • 非常感谢,我会尽快尝试(并非所有日子我都可以使用打印机和抽屉)。我试图使用 PosExplorer 库,但无法识别视觉。我认为实用程序 SetupPos.exe 附带打印机的安装光盘。谢谢
  • 不要忘记在您的项目中添加对 Microsoft.PointOfService.dll 的引用。这可能是 VS 无法识别它的原因。
  • 是的,我在一些示例中找到了该引用,但我的 VS 没有识别它。也许我必须先安装 SetupPos.exe。今天我来试试。谢谢:)
  • 现在我可以打印了,但我正在尝试发送代码来剪纸并打印徽标(使用 epson 的软件存储在打印机中),但打印机不做任何事情。有什么建议吗?
  • @uoah 你能发布你正在做什么来发送剪纸和打印徽标命令吗?然后我就可以看到问题所在了。
【解决方案3】:

对于那些尝试使用 VB.NET 和 POS.NET 执行此操作的用户,请将其发送到打印机:

m_printer = the instance you created for the PosExplorer
m_printer.PrintNormal(PrinterStation.Receipt, System.Text.ASCIIEncoding.ASCII.GetString(New Byte() {27, 112, 48, 55, 121}))

这适用于我的 Epson TM-T20

奇怪的是它不会在第一次发送时打开,而是每次发送后都打开。

【讨论】:

    猜你喜欢
    • 2020-04-01
    • 2016-12-01
    • 2022-10-17
    • 2014-01-19
    • 2012-10-05
    • 2013-12-03
    • 2021-01-06
    • 2016-05-05
    相关资源
    最近更新 更多