问题描述
我试图通过向打印机(带有 USB 端口的 Epson TM U220)发送剪纸命令来务实地剪纸.我在安装后找到了带有通用/纯文本驱动程序和爱普生打印机端口的打印机爱普生高级打印机驱动程序.打印机命令代码是 (GS V m),其中 m = 0、1、48 或 49,这是我在设备手册中找到的.我想知道如何通过 StringWriter 将这些命令发送到打印机.我使用 Generic/Text Only 打印机,因为它比使用 Epson 驱动程序快得多.
I'm trying to cut the paper pragmatically by sending paper cut command to the printer (Epson TM U220 with USB port).I used the printer with Generic/Text Only Driver and Epson printer port which I found after installingEpson advanced printer driver. Printer command code is (GS V m), where m = 0,1,48 or 49 which I found on the device manual.I would like to know how to send these command to printer by StringWriter.I use Generic/Text Only printer because it's much faster than using Epson driver.
我真的是 C# windows 的新手,请任何人为我提供一些代码行来实现这一点.我已经在网上冲浪了几天,但仍然没有找到答案.我想我需要将打印机命令作为字节发送,但我不知道该怎么做:(
I'm really new to C# windows and please anyone kindly provide me some lines of code to achieve this. I've been surfing the web for several days and still not found the answer yet. I think I need to send printer command as byte but I don't know how to do :(
推荐答案
非常感谢 Hans.现在我可以使用 Microsoft RawPrinterHelper 类发送剪纸命令.我一直在寻找这个解决方案六天了.这是我所做的.
Thank you very much Hans. Now I can send Paper cut command by using Microsoft RawPrinterHelper class. I've been seeking this solution for six days. Here is what I've done.
string GS = Convert.ToString((char)29);
string ESC = Convert.ToString((char)27);
string COMMAND = "";
COMMAND = ESC + "@";
COMMAND += GS + "V" + (char)1;
PrintDialog pd = new PrintDialog();
pd.PrinterSettings = new PrinterSettings();
if (DialogResult.OK == pd.ShowDialog(this))
{
RawPrinterHelper.SendStringToPrinter(pd.PrinterSettings.PrinterName, COMMAND);
}
这篇关于如何向爱普生打印机发送切页命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!