csharp 来自http://forums.asp.net/t/1738967.aspx?Print+with+thermal+printer

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了csharp 来自http://forums.asp.net/t/1738967.aspx?Print+with+thermal+printer相关的知识,希望对你有一定的参考价值。

using System;
using System.Drawing;
using System.Drawing.Printing;
using System.IO;
using System.IO.Ports;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Drawing.Text;
using System.Drawing.Design;
using System.Drawing.Imaging;
 
namespace ShippingStation_csharp
{
    class clsPrinter
    {
        public SerialPort ComPort1 = new SerialPort("COM1", 9600, Parity.None, 8, StopBits.One);
        public SerialPort ComPort2 = new SerialPort("COM2", 9600, Parity.None, 8, StopBits.One);
        ///
 
        [STAThread]
        static void Main(string[] args)
        {
 
        }
 
        public clsPrinter()
        {
 
        }
 
        public void InitShippingPrinter(SerialPort m_pPortCom)
        {
            SendCommandToPrinter(m_pPortCom, "\nN");
            SendCommandToPrinter(m_pPortCom, "D7");
            SendCommandToPrinter(m_pPortCom, "S2");
            SendCommandToPrinter(m_pPortCom, "ZT");
            SendCommandToPrinter(m_pPortCom, "Q1800,36");
            SendCommandToPrinter(m_pPortCom2, "q1200");
        }
 
        public void InitSerialPrinter(SerialPort m_pPortCom)
        {
            SendCommandToPrinter(m_pPortCom, "\nN");
            SendCommandToPrinter(m_pPortCom, "D7");
            SendCommandToPrinter(m_pPortCom, "S1");
            SendCommandToPrinter(m_pPortCom, "ZT");
            SendCommandToPrinter(m_pPortCom, "Q450,36");
            SendCommandToPrinter(m_pPortCom, "q900");
        }
 
        public void PrintToPrinter(PrintPageEventHandler PagetoPrint)
        {
            PrintDocument tPrinter = new PrintDocument();
            tPrinter.PrintPage += new PrintPageEventHandler(PagetoPrint);
            tPrinter.Print();
        }
 
        public void ComPortData(SerialPort port, string cmd)
        {
            SendCommandToPrinter(port, cmd);
        }
 
        private static void SendTextFile(SerialPort port, string FileName)
        {
            port.Write(File.OpenText(FileName).ReadToEnd());
        }
 
        private void SendCommandToPrinter(SerialPort port, string cmd)
        {
            string str = null;
            str=cmd + "\n";
            port.Write(str);
        }
 
     
 
    }
}

以上是关于csharp 来自http://forums.asp.net/t/1738967.aspx?Print+with+thermal+printer的主要内容,如果未能解决你的问题,请参考以下文章

csharp 来自csvj的getFrameworkVersion在tfvc上

csharp 来自http://www.codemag.com/Article/1312081

csharp 来自http://www.codemag.com/Article/1312081

csharp 来自http://www.codemag.com/Article/1312081

csharp 来自http://www.codemag.com/Article/1312081

csharp HMACSHA256来自http://ideone.com/JdpeL