Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

I want to print the receipt to thermal printer without using OPOS driver.

Please guide me in this case.

Thanks
Posted
Comments
Abdul Quader Mamun 16-Feb-11 5:09am    
Is it possible without driver?
prashant1111 16-Feb-11 5:43am    
Yes, It is possible But I dont know How ?
Albin Abel 16-Feb-11 5:38am    
you may use ESC/POS commands also. it would be easier. Some of the thermal printers connected to USB / parallel port can be printed using the .net printing method. No need drivers. I have used ESC/POS for a receipt print connected to COM and print barcode printer connected to USB using normal printing drivers available in .Net
prashant1111 16-Feb-11 5:43am    
How to use that command
prashant1111 16-Feb-11 5:52am    
YEs AlbinAble you are right. My printer is connected through Port and I want to print using that port. SO what approach I follow to achieve this. But keep in mind that no OPOS driver is installed on the system. I want to print the receipt on that printer.

Hi Create a Generic text printer in the pc (Add new Printer...or google it how to add a generic text printer)

Look at this article how to send raw data to printer.

http://support.microsoft.com/kb/322090[^]

using this you can send ESC/POS commands to the printer.

For ESC/POS commands reference use this link http://www.google.co.in/url?sa=t&source=web&cd=1&ved=0CBYQFjAA&url=http%3A%2F%2Fnicholas.piasecki.name%2Fblog%2Fwp-content%2Fuploads%2F2009%2F12%2FESC-POS-Command-Guide.pdf&ei=kaxbTcvZI8uXcde_iNoK&usg=AFQjCNFX385l9jOit_86cfsoHmpH4kPKKQ[^]

or google it for more
 
Share this answer
 
1.Create Handle for printer using printer port
2.WriteFile(Handle,"Str",len,0,NULL)
 
Share this answer
 
Comments
Member 10296413 25-Sep-13 6:00am    
Hi I need to print a recept in thermal printer connected in USB
C#
public partial class frmBook : Form
   {



       public const Int32 FILE_ATTRIBUTE_NORMAL = 128;//Intializing Port Attributes
       public const Int32 INVALID_HANDLE_VALUE = -1;
       public const Int32 GENERIC_READ = -2147483648;
       public const Int32 GENERIC_WRITE = 1073741824;
       public const Int32 CREATE_NEW = 1;
       public const Int32 CREATE_ALWAYS = 2;
       public const Int32 OPEN_EXISTING = 3;




 protected void Print_Ticket(string ticketNo, string seatNo, string Showtime, string Price)
        {

            IntPtr ptr = CreateFile("LPT1", GENERIC_WRITE, 0,
             IntPtr.Zero, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, IntPtr.Zero);

            /* Is bad handle? INVALID_HANDLE_VALUE */
            if (ptr.ToInt32() == -1)
            {
                /* ask the framework to marshall the win32 error code to an exception */
                Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error());
            }
            else
            {

                /////// Print Reciept Print//////
                FileStream lpt = new FileStream(ptr, FileAccess.ReadWrite);
                byte[] LineFeedChar = new byte[] { 13, 10 };
                byte[] BackNormalChar = new byte[] { 27, 33, 0 };
                byte[] CuttingChar = new byte[] { 29, 86, 66 };

                Byte[] buf_TheaterName = new Byte[8048];
                Byte[] buf_Address = new Byte[8048];
                Byte[] buf_Line1 = new Byte[8048];
                Byte[] buf_TicketNo = new Byte[8048];
                Byte[] buf_Date = new Byte[8048];
                Byte[] buf_SeatNo = new Byte[8048];
                Byte[] buf_Showtime = new Byte[8048];
                Byte[] buf_Price = new Byte[8048];
                Byte[] buf_FooterMsg = new Byte[8048];

                StringBuilder strFooter = new StringBuilder();
                lpt.Write(CuttingChar, 0, 3); //
                buf_TheaterName = System.Text.Encoding.ASCII.GetBytes("           " + cmbTheatre.Text.ToString() + "             ");
                lpt.Write(buf_TheaterName, 0, buf_TheaterName.Length);
                lpt.Write(LineFeedChar, 0, 2);
                buf_TicketNo = System.Text.Encoding.ASCII.GetBytes("Ticket No :".PadLeft(9) + ticketNo.PadLeft(3));//
                lpt.Write(buf_TicketNo, 0, buf_TicketNo.Length);//

                lpt.Write(LineFeedChar, 0, 2);
                buf_Date = System.Text.Encoding.ASCII.GetBytes("Date      :".PadLeft(9) + dteBookDate.Text.PadLeft(3));
                lpt.Write(buf_Date, 0, buf_Date.Length);
                lpt.Write(LineFeedChar, 0, 2);

                buf_SeatNo = System.Text.Encoding.ASCII.GetBytes("Seat No   :".PadLeft(9) + seatNo.PadLeft(3));
                lpt.Write(buf_SeatNo, 0, buf_SeatNo.Length);
                lpt.Write(LineFeedChar, 0, 2);
                buf_Showtime = System.Text.Encoding.ASCII.GetBytes("Show Time :".PadLeft(9) + Showtime.PadLeft(3));
                lpt.Write(buf_Showtime, 0, buf_Showtime.Length);
                lpt.Write(LineFeedChar, 0, 2);
                buf_Price = System.Text.Encoding.ASCII.GetBytes("Price     :".PadLeft(9) + Price.PadLeft(3));
                lpt.Write(buf_Price, 0, buf_Price.Length);
                lpt.Write(LineFeedChar, 0, 2);

                buf_FooterMsg = System.Text.Encoding.ASCII.GetBytes("              Thank You  Visit Agin      ");
                lpt.Write(buf_FooterMsg, 0, buf_FooterMsg.Length);
                lpt.Write(LineFeedChar, 0, 2);
                lpt.Write(CuttingChar, 0, 3);
                lpt.Write(BackNormalChar, 0, 3);
                
                lpt.Close();
            }
}
 
Share this answer
 
v2
Comments
Member 10626384 25-Oct-19 6:31am    
how to break line if Name of some character example New Ice and Hokey now may be
we need to break after ice

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900