日期:2014-05-19  浏览次数:20985 次

哪位大哥大姐能提供段C#输出ESC打印指令的代码,100分相赠
用.net的PrintDocument打印速度太慢,我做的打印需要打到POS热敏打印机,但是也要支持普通激光打印机,用PrintDocument打印速度太慢,想采用API     WrintPrinter的方式打印,但是字体什么的很难控制,只能用ESP打印指令了,一般的POS打印机都支持普通ESC,大部分激光打印机也支持吧。

------解决方案--------------------
請參照http://www.codeproject.com/tools/arabicreceiptprint.asp,有例子和源碼,具體代碼摘錄如下:
<PRE id=pre0 style= "MARGIN-TOP: 0px "> // The activeX control name is: PrnX for example
void InitPrn (CString pComPort)
{
PrnX.OpenPort (pComPort);
PrnX.Reset(); //Rest the printer

//1 = 79 Figures(extended mode for Citizin CBM printers and similars)
//2 = 32 Figures(restricted mode for Epson & 32
// International characters only)
PrnX.SetChMode (1);

PrnX.Init();
//Initialize the printer status & buffer

PrnX.LoadCharsDefs();
//Load the international characters into the printer

}

void PrintText (CString pText, short pAllignment)
{
// Left, Center, Right PrnX.SetAllignment (pAllignment);

//vLines = Number of empty lines after the print operation. Can be Zero
short vLines = 2;

// Print now as you want.
// pText may be " any local/english text here
// -arabic version here- " PrnX.CBMPrint (pText, vLines);

//And can use PrnX.FeedLine(vLines) also

//And can do PrnX.CutSheet() to cut the paper if the printer support it
}

void ClosePrnPort ()
{
PrnX.ClosePort();
} </PRE>
------解决方案--------------------
UP.~~~~~~~~
------解决方案--------------------
UP

------解决方案--------------------
关注,我是用PrintDocument做的
期待更多方案!