现在正在做一个程序,需要连接小票打印机,而且是RJ45接口的。  请教一下各位 有这方面的例子吗?小弟想学习一下

解决方案 »

  1.   

    百度  google  是最后的老师!
      

  2.   

    你买打印机的时候他们没有提供API吗???
      

  3.   

    买打印机的时候有API借口的例子
      

  4.   

    水晶报表打印小票啊。
    //upd by hu 20100608 交易小票打印
    PrintDocument prtdoc = new PrintDocument();
    string strDefaultPrinter = prtdoc.PrinterSettings.PrinterName;//获取默认的打印机名 if (strDefaultPrinter.ToUpper() == "POS58") //判断是否为默认打印机
    {
    DataTable print_dt = new DataTable();
    string salecd = cs.salecd; rtn = cs.GetdataDetail(1);
    if (rtn == ComConst.FAILED)
    {
    if (cs.errMode)
    {
    lblMsg.Text = cs.strErr;
    }
    else
    {
    ComLibrary.getMsg(cs.strErr, "E", "错误");
    }
    lblMsg.ForeColor = Color.Red;
    return;
    } #region 添加列 print_dt.Columns.Add("SALECD", typeof(string));
    print_dt.Columns.Add("CRID", typeof(string));
    print_dt.Columns.Add("SALEDATE", typeof(decimal));
    print_dt.Columns.Add("ITEMCD", typeof(string));
    print_dt.Columns.Add("ITEMNAME", typeof(string));
    print_dt.Columns.Add("TYPECD", typeof(string));
    print_dt.Columns.Add("TYPENAME", typeof(string));
    print_dt.Columns.Add("PRICE", typeof(decimal));
    print_dt.Columns.Add("QTY", typeof(decimal));
    //print_dt.Columns.Add("UNITCD", typeof(string));
    //print_dt.Columns.Add("DISCOUNT", typeof(decimal));
    print_dt.Columns.Add("SUMAMT", typeof(decimal));
    print_dt.Columns.Add("ITEMTY", typeof(string));
    //print_dt.Columns.Add("ADJUSTAMT", typeof(decimal));
    //print_dt.Columns.Add("ACTAMT", typeof(decimal));
    //print_dt.Columns.Add("CHANGE", typeof(decimal));
    print_dt.Columns.Add("COMPANY", typeof(string));
    print_dt.Columns.Add("ADDRESS", typeof(string));
    print_dt.Columns.Add("TEL", typeof(string));
    print_dt.Columns.Add("NOTE", typeof(string));
    #endregion
    for (int i = 0; i < dgvITList.RowCount - 1; i++)
    {
    print_dt.Rows.Add(salecd, ComLibrary.ToString(this.Tag), ComLibrary.ToInt(dtpSalesDate.txtDate.Text),//upd by hu 20100701
    dgvITList.Rows[i].Cells[COLITEMCD].Value, dgvITList.Rows[i].Cells[COLITEMNM].Value,
    dgvITList.Rows[i].Cells[COLTYPECD].FormattedValue, dgvITList.Rows[i].Cells[COLTYPENM].Value,
    ComLibrary.ToDecimal(dgvITList.Rows[i].Cells[COLSELLPRICE].Value), ComLibrary.ToInt(dgvITList.Rows[i].Cells[COLAMOUNT].Value),
    ComLibrary.ToDecimal(dgvITList.Rows[i].Cells[COLMONEY].Value),
     dgvITList.Rows[i].Cells[COLITEMTYPE].Value, cs.company, cs.address, cs.tel, cs.note);
    } try
    {
    //打印
    this.Cursor = Cursors.WaitCursor;
    CsReport.CS012CLS report = new LMS.CsReport.CS012CLS();
    report.Viewer = false;
    report.ZoomLevel = 100;
    report.FormWindowState = FormWindowState.Maximized;
    report.SetDataSource(print_dt);
    report.Publish();
    }
    catch (Exception ew)
    {
    ComLibrary.getMsg(ew.Message, "E", "错误");
    }
    finally
    {
    this.Cursor = Cursors.Default;
    }
    }
    /********************************************************************/
    ComLibrary.ClearControl(pnlDetail);
    ComLibrary.ClearControl(pnlKey);
    comScomb.Rows.Clear();
    dtpSalesDate.txtDate.Text = DateTime.Now.ToString("yyyyMMdd");//upd by hu 20100701
    rdoNVip.Focus();
    }
      

  5.   

    你可以做个EXCEL模版,(做成你小票需要的格式).然后再将数据写入到EXCEL模版中,再打印.这些和是什么口的打印机没关系.
      

  6.   

    打印机厂家会提供JDK开发接口或者dll接口,要说明文档或者demo程序。
      

  7.   

    安装驱动;有程式设计时用System.Drawing.Printing 最简单