发送ESC命令在C#中的打印机 [英] Send ESC commands to a printer in C#

查看:259
本文介绍了发送ESC命令在C#中的打印机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序需要打印发票,然后从数据库中获得发票,将在一个大串的发票信息(说的是行,列等)在此之后我有串准备发送到打印机

My application needs to print invoices, then a get the invoice from database, insert information on the invoice in a big string (telling the line, column, etc.) after this I have the string ready to be sent to a printer.

我的问题是:我需要把一些ESC / P命令/在我的大字符串中的字符

My problem is: I need to put some ESC/P commands/characters in my big string

我试图做这样的事情:

        char formFeed = (char)12;
        Convert.ToChar(12);

        MyBigString.Insert(10, formFeed);



这蒙山,10号线将做一个换页,但这不起作用。

Whith this, the line 10 will do a FormFeed, but this doesn't work

请注意:我送MybigString一下子打印机

NOTE: I send the MybigString all at once to the printer.

为了让我的代码工作,我需要发送的。通过线数据线到打印机

To make my code works, I need to send the data line by line to a printer?

感谢您的帮助。

PS:对不起,我的英语水平,我'巴西开发人员不说英语(还)。

PS: Sorry, for my English, I'am a Brazilian developer which don't speak English (yet).

推荐答案

绕过打印机驱动程序和控制打印机直接使用其固有的命令语言,是一个支持的方案。在P / Invoke的是在这个知识库文章很好地解释。

Bypassing the printer driver and controlling the printer directly, using its native command language, is a supported scenario. The P/Invoke is explained well in this KB article.

确定要这么做吗?这是罕见的,说得客气一点,通常只尝试低成本点的销售热或点阵打印机。如果你不喜欢PrintDocument.PrintPage的机制,没有人做,你可以考虑我的的此线程。注意换页方法。

Sure you want to do this? It is uncommon, to put it mildly, usually only attempted with low-cost Point-Of-Sale thermal or matrix printers. If you don't like the mechanics of PrintDocument.PrintPage, nobody does, you could consider my code in this thread. Note the FormFeed method.

这篇关于发送ESC命令在C#中的打印机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆