简体   繁体   English

为什么“€”字符只在打印机初始化之前打印,而不是在初始化之后?

[英]Why is the “€” character only printed before printer initialization and not after the initialization?

I have an Epson TM-T88VI printer and use the Microsoft.PointOfService.PosPrinter in C# for printing.我有一台 Epson TM-T88VI 打印机并使用 C# 中的 Microsoft.PointOfService.PosPrinter 进行打印。

Using the following function i get a strange output printed:使用以下 function 我得到一个奇怪的 output 打印:

    public static void printerTestFunction2(string printerName)
    {
        PosExplorer explorer = new PosExplorer();
        DeviceInfo di = explorer.GetDevice("PosPrinter", printerName);
        PosPrinter printer = (PosPrinter)explorer.CreateInstance(di);

        printer.Open();
        printer.Claim(10000);
        printer.DeviceEnabled = true;
        printer.AsyncMode = false;

        string init = System.Text.ASCIIEncoding.ASCII.GetString(new byte[] { 27, 64 });
        string totalCut = System.Text.ASCIIEncoding.ASCII.GetString(new byte[] { 27, 105 });
        string cmd = init + init + "A€A\nB€B\n" + init + "C€C\nD€D\n\n\n\n\n\n\n" + totalCut;
        printer.PrintNormal(PrinterStation.Receipt, cmd);
    }

The output is: output 是:

A€A欧元

B€B早餐

CFC氟氯化碳

DFD DFD

在此处输入图像描述

So the € symbol is printed as a strange "F" symbol (seems like the F is lower than the normal characters).因此,€ 符号被打印为一个奇怪的“F”符号(似乎 F 低于普通字符)。 The paper is cut correctly.纸张被正确裁切。

I also have tested different constellations.我也测试了不同的星座。 It seems that the "€" sign is only printed before the first init command which is send to the printer after at least one row has been printed out.似乎“€”符号仅在打印出至少一行后发送到打印机的第一个 init 命令之前打印。 (I can send multiple init commands at the beginning - the € is printed. If i send the init after some chars have been printed, the "F" will appear instead of the "€"). (我可以在开始时发送多个初始化命令 - 打印€。如果我在打印一些字符后发送初始化,“F”将出现而不是“€”)。 If I restart my program, the "€" is again printed correctly, but if i send the init command it will be printed as "F" again.如果我重新启动程序,“€”会再次正确打印,但如果我发送 init 命令,它将再次打印为“F”。

What is the reason that the "€" symbol is only printed before the third init command? “€”符号仅在第三个 init 命令之前打印的原因是什么? Is there anything wrong with my code or do i miss a setting?我的代码有什么问题还是我错过了某个设置?

The reason why letters like F are printed is because the printer is in the initialized state, code page 437.之所以打印F之类的字母,是因为打印机在初始化的state,代码页437。
Look at the letters in the following material at 213 in decimal and 0xD5 in hexadecimal.查看以下材料中的十进制 213 和十六进制 0xD5 中的字母。

Page 0 [PC437: USA, Standard Europe] 第 0 页 [PC437:美国,标准欧洲]

Page 19 [PC858: Euro] 第 19 页 [PC858:欧元]


The POS for.NET service object internally manages code page settings according to the value of CharacterSet property. POS for .NET 服务 object 在内部根据 CharacterSet 属性的值管理代码页设置。

If the application arbitrarily sends initialization commands to the printer, the service object's management information may be inconsistent and the printer may print incorrectly.如果应用程序随意向打印机发送初始化命令,可能会导致服务对象的管理信息不一致,导致打印机打印不正确。

If you are using POS for.NET (including OPOS/JavaPOS), you should not use the initialization command (ESC@) or similar commands to change the mode or settings.如果您使用 POS for.NET(包括 OPOS/JavaPOS),则不应使用初始化命令 (ESC@) 或类似命令来更改模式或设置。

In that sense, instead of sending the paper cut also directly the ESC i({ 27, 105 }) command, call the CutPaper method or put the POSPrinter paper cut escape sequence (ESC|P) defined in UnifiedPOS in the print request string.从这个意义上说,不是也直接发送剪纸 ESC i({ 27, 105 }) 命令,而是调用 CutPaper 方法或将 UnifiedPOS 中定义的 POSPrinter 剪纸转义序列 (ESC|P) 放入打印请求字符串中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM