private const string PRTSIZE_1 = "esc w 1";//倍宽打印命令
         private const string PRTSIZE_0 = "esc w 0";//解除倍宽打印命令

private string PrintStr="测试打印";
        /// <summary>
        /// 字符串打印
        /// </summary>
        /// <param name="PrintString"></param>
        private void butClick(string PrintToJavaScript)
        {
            printDialog1 = new PrintDialog();
            ThePrintDocument = new PrintDocument();
            ThePrintDocument.PrintPage += new PrintPageEventHandler(ThePrintDocument_PrintPage);            printDialog1.Document = ThePrintDocument;
            string strText = PrintToJavaScript;
            myReader = new StringReader(PrintStr);
            if (printDialog1.ShowDialog() == DialogResult.OK)
            {
                ThePrintDocument.Print();
            }
        }我的代码基本如上面所写.现在问题是在控制倍宽打印上,打印机根本不认打印控制码(打印控制码我是从打印说明书上弄到的)!!! 这问题搞的很头大. 请各位革命同志给出个指导方向,如果有详细点的解决方法最好,分不是问题.

解决方案 »

  1.   

    回复 kkun_3yue3打印是支持的,原因要解释比较麻烦,但是可以肯定排除这方面的原因.
      

  2.   

    TO zlkingdom 我现在控制码也是从该型号的打印说明书抄下来的. 
      

  3.   

    这个命令打印机不能识别。 esc 是一个控制指令,对应的字符代码为 27,,你这样写是不行的 
    ,贴个例子给大家看看:
    const char DC1 = 17;
    const char DC3 = 19;
    const char ESC = 27;
    const char DLE = 16;
    const char FF = 12;
    const char LF = 10;
    const char CR = 13;
    const char CEX = 28;
    const int MAX_CMD_LEN = 50;float gLastPosX = 0.0;
    float gLastPosY = 0.0;//初始化
    extern "C" void InitPrinter(LPTSTR& CmdString, long& Len)
    {
    memset(CmdString,0,Len); char* Result = (char*)malloc(1+2+2);
    memset(Result,0,1+2+2);
    char TmpCmd[10];
    int Pos = 0; //联机
    TmpCmd[0] = DC1;
    memcpy(Result+Pos, TmpCmd, 1);
    Pos += 1;
    //初始化
    TmpCmd[0] = DLE;
    TmpCmd[1] = 'B';
    memcpy(Result+Pos, TmpCmd, 2);
    Pos += 2;
    //1/6英寸行距
    TmpCmd[0] = ESC;
    TmpCmd[1] = '6';
    memcpy(Result+Pos, TmpCmd, 2);
    Pos += 2; REALLOCMEMERY(Len,Pos)
    Len = Pos;
    free(Result);
    }